public abstract class PrintStreamOutput extends Object implements StoryReporter
Abstract story reporter that outputs to a PrintStream.
The output of the reported event is configurable via:
Let's look at example of providing custom output patterns, e.g. for the
failed event.
we'd need to provide the custom pattern, say we want to have something like
"(step being executed) <<< FAILED", keyed on the method name:
Properties patterns = new Properties();
patterns.setProperty("failed", "{0} <<< {1}");
The pattern is by default processed and formatted by the
MessageFormat. Both the
format(String key, String defaultPattern, Object... args) and
lookupPattern(String key, String defaultPattern) methods are
override-able and a different formatter or pattern lookup can be used by
subclasses.
If the keyword "FAILED" (or any other keyword used by the reporter) needs to
be expressed in a different language, all we need to do is to provide an
instance of LocalizedKeywords using the
appropriate Locale, e.g.
Keywords keywords = new LocalizedKeywords(new Locale("it"));
| Modifier and Type | Class and Description |
|---|---|
static class |
PrintStreamOutput.Format |
| Modifier | Constructor and Description |
|---|---|
protected |
PrintStreamOutput(PrintStreamOutput.Format format,
PrintStream output,
Properties outputPatterns,
Keywords keywords,
boolean reportFailureTrace,
boolean compressFailureTrace) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterExamples() |
void |
afterScenario() |
void |
afterStory(boolean givenOrRestartingStory) |
void |
beforeExamples(List<String> steps,
ExamplesTable table) |
void |
beforeScenario(String title) |
void |
beforeStep(String step) |
void |
beforeStory(Story story,
boolean givenStory) |
void |
comment(String step) |
boolean |
compressFailureTrace() |
PrintStreamOutput |
doCompressFailureTrace(boolean compressFailureTrace) |
PrintStreamOutput |
doReportFailureTrace(boolean reportFailureTrace) |
void |
dryRun() |
protected Object[] |
escape(PrintStreamOutput.Format format,
Object... args)
Escapes args' string values according to format
|
void |
example(Map<String,String> tableRow) |
void |
failed(String step,
Throwable storyFailure) |
void |
failedOutcomes(String step,
OutcomesTable table) |
protected String |
format(String key,
String defaultPattern,
Object... args)
Formats event output by key, usually equal to the method name.
|
protected String |
formatTable(ExamplesTable table) |
void |
givenStories(GivenStories givenStories) |
void |
givenStories(List<String> storyPaths) |
void |
ignorable(String step) |
void |
lifecyle(Lifecycle lifecycle) |
protected String |
lookupPattern(String key,
String defaultPattern)
Looks up the format pattern for the event output by key, conventionally
equal to the method name.
|
void |
narrative(Narrative narrative) |
void |
notPerformed(String step) |
protected void |
overwritePattern(String key,
String pattern) |
void |
pending(String step) |
void |
pendingMethods(List<String> methods) |
protected void |
print(String text)
Prints text to output stream, replacing parameter start and end
placeholders
|
boolean |
reportFailureTrace() |
void |
restarted(String step,
Throwable cause) |
void |
restartedStory(Story story,
Throwable cause) |
void |
scenarioMeta(Meta meta) |
void |
scenarioNotAllowed(Scenario scenario,
String filter) |
void |
storyCancelled(Story story,
StoryDuration storyDuration) |
void |
storyNotAllowed(Story story,
String filter) |
void |
successful(String step) |
String |
toString() |
protected PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace)
public void beforeStep(String step)
beforeStep in interface StoryReporterpublic void successful(String step)
successful in interface StoryReporterpublic void ignorable(String step)
ignorable in interface StoryReporterpublic void comment(String step)
comment in interface StoryReporterpublic void pending(String step)
pending in interface StoryReporterpublic void notPerformed(String step)
notPerformed in interface StoryReporterpublic void failed(String step, Throwable storyFailure)
failed in interface StoryReporterpublic void failedOutcomes(String step, OutcomesTable table)
failedOutcomes in interface StoryReporterpublic void storyNotAllowed(Story story, String filter)
storyNotAllowed in interface StoryReporterpublic void storyCancelled(Story story, StoryDuration storyDuration)
storyCancelled in interface StoryReporterpublic void beforeStory(Story story, boolean givenStory)
beforeStory in interface StoryReporterpublic void narrative(Narrative narrative)
narrative in interface StoryReporterpublic void lifecyle(Lifecycle lifecycle)
lifecyle in interface StoryReporterpublic void afterStory(boolean givenOrRestartingStory)
afterStory in interface StoryReporterpublic void givenStories(GivenStories givenStories)
givenStories in interface StoryReporterpublic void givenStories(List<String> storyPaths)
givenStories in interface StoryReporterpublic void scenarioNotAllowed(Scenario scenario, String filter)
scenarioNotAllowed in interface StoryReporterpublic void beforeScenario(String title)
beforeScenario in interface StoryReporterpublic void scenarioMeta(Meta meta)
scenarioMeta in interface StoryReporterpublic void afterScenario()
afterScenario in interface StoryReporterpublic void beforeExamples(List<String> steps, ExamplesTable table)
beforeExamples in interface StoryReporterpublic void example(Map<String,String> tableRow)
example in interface StoryReporterpublic void afterExamples()
afterExamples in interface StoryReporterpublic void dryRun()
dryRun in interface StoryReporterpublic void pendingMethods(List<String> methods)
pendingMethods in interface StoryReporterpublic void restarted(String step, Throwable cause)
restarted in interface StoryReporterpublic void restartedStory(Story story, Throwable cause)
restartedStory in interface StoryReporterprotected String format(String key, String defaultPattern, Object... args)
key - the event keydefaultPattern - the default pattern to return if a custom pattern
is not foundargs - the args used to format outputprotected String formatTable(ExamplesTable table)
protected Object[] escape(PrintStreamOutput.Format format, Object... args)
format - the Format used by the PrintStreamargs - the array of args to escapeprotected String lookupPattern(String key, String defaultPattern)
MessageFormat.format(String, Object...) method. If no
pattern is found for key or needs to be overridden, the default pattern
should be returned.key - the format pattern keydefaultPattern - the default pattern if no pattern ispublic boolean reportFailureTrace()
public PrintStreamOutput doReportFailureTrace(boolean reportFailureTrace)
public boolean compressFailureTrace()
public PrintStreamOutput doCompressFailureTrace(boolean compressFailureTrace)
protected void print(String text)
text - the String to printCopyright © 2003–2016. All rights reserved.