public abstract class PrintStreamOutput extends NullStoryReporter
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) |
protected |
PrintStreamOutput(PrintStreamOutput.Format format,
PrintStream output,
Properties defaultPatterns,
Properties outputPatterns,
Keywords keywords) |
protected |
PrintStreamOutput(PrintStreamOutput.Format format,
PrintStream output,
Properties defaultPatterns,
Properties outputPatterns,
Keywords keywords,
boolean reportFailureTrace,
boolean compressFailureTrace) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterExamples() |
void |
afterGivenStories() |
void |
afterScenario() |
void |
afterStory(boolean givenOrRestartingStory) |
void |
afterStorySteps(StepCollector.Stage stage) |
void |
beforeExamples(List<String> steps,
ExamplesTable table) |
void |
beforeGivenStories() |
void |
beforeScenario(Scenario scenario) |
void |
beforeStep(String step) |
void |
beforeStory(Story story,
boolean givenStory) |
void |
beforeStorySteps(StepCollector.Stage stage) |
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,
int exampleIndex) |
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) |
protected String |
formatVerbatim(Verbatim verbatim) |
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(PrintStream output,
String text) |
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 |
scenarioNotAllowed(Scenario scenario,
String filter) |
void |
storyCancelled(Story story,
StoryDuration storyDuration) |
void |
storyNotAllowed(Story story,
String filter) |
void |
successful(String step) |
String |
toString() |
protected String |
transformPrintingTable(String text,
String tableStart,
String tableEnd) |
protected String |
transformPrintingVerbatim(String text,
String verbatimStart,
String verbatimEnd) |
afterScenarioSteps, beforeScenario, beforeScenarioSteps, example, scenarioMetapublic static final String NL
protected PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties defaultPatterns, Properties outputPatterns, Keywords keywords)
protected PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties defaultPatterns, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace)
protected PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace)
public void beforeStep(String step)
beforeStep in interface StoryReporterbeforeStep in class NullStoryReporterpublic void successful(String step)
successful in interface StoryReportersuccessful in class NullStoryReporterpublic void ignorable(String step)
ignorable in interface StoryReporterignorable in class NullStoryReporterpublic void comment(String step)
comment in interface StoryReportercomment in class NullStoryReporterpublic void pending(String step)
pending in interface StoryReporterpending in class NullStoryReporterpublic void notPerformed(String step)
notPerformed in interface StoryReporternotPerformed in class NullStoryReporterpublic void failed(String step, Throwable storyFailure)
failed in interface StoryReporterfailed in class NullStoryReporterpublic void failedOutcomes(String step, OutcomesTable table)
failedOutcomes in interface StoryReporterfailedOutcomes in class NullStoryReporterpublic void storyNotAllowed(Story story, String filter)
storyNotAllowed in interface StoryReporterstoryNotAllowed in class NullStoryReporterpublic void storyCancelled(Story story, StoryDuration storyDuration)
storyCancelled in interface StoryReporterstoryCancelled in class NullStoryReporterpublic void beforeStory(Story story, boolean givenStory)
beforeStory in interface StoryReporterbeforeStory in class NullStoryReporterpublic void narrative(Narrative narrative)
narrative in interface StoryReporternarrative in class NullStoryReporterpublic void lifecyle(Lifecycle lifecycle)
lifecyle in interface StoryReporterlifecyle in class NullStoryReporterpublic void beforeStorySteps(StepCollector.Stage stage)
beforeStorySteps in interface StoryReporterbeforeStorySteps in class NullStoryReporterpublic void afterStorySteps(StepCollector.Stage stage)
afterStorySteps in interface StoryReporterafterStorySteps in class NullStoryReporterpublic void afterStory(boolean givenOrRestartingStory)
afterStory in interface StoryReporterafterStory in class NullStoryReporterpublic void beforeGivenStories()
beforeGivenStories in interface StoryReporterbeforeGivenStories in class NullStoryReporterpublic void givenStories(GivenStories givenStories)
givenStories in interface StoryReportergivenStories in class NullStoryReporterpublic void givenStories(List<String> storyPaths)
givenStories in interface StoryReportergivenStories in class NullStoryReporterpublic void afterGivenStories()
afterGivenStories in interface StoryReporterafterGivenStories in class NullStoryReporterpublic void scenarioNotAllowed(Scenario scenario, String filter)
scenarioNotAllowed in interface StoryReporterscenarioNotAllowed in class NullStoryReporterpublic void beforeScenario(Scenario scenario)
beforeScenario in interface StoryReporterbeforeScenario in class NullStoryReporterpublic void afterScenario()
afterScenario in interface StoryReporterafterScenario in class NullStoryReporterpublic void beforeExamples(List<String> steps, ExamplesTable table)
beforeExamples in interface StoryReporterbeforeExamples in class NullStoryReporterpublic void example(Map<String,String> tableRow, int exampleIndex)
example in interface StoryReporterexample in class NullStoryReporterpublic void afterExamples()
afterExamples in interface StoryReporterafterExamples in class NullStoryReporterpublic void dryRun()
dryRun in interface StoryReporterdryRun in class NullStoryReporterpublic void pendingMethods(List<String> methods)
pendingMethods in interface StoryReporterpendingMethods in class NullStoryReporterpublic void restarted(String step, Throwable cause)
restarted in interface StoryReporterrestarted in class NullStoryReporterpublic void restartedStory(Story story, Throwable cause)
restartedStory in interface StoryReporterrestartedStory in class NullStoryReporterprotected 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 printprotected String transformPrintingTable(String text, String tableStart, String tableEnd)
protected String transformPrintingVerbatim(String text, String verbatimStart, String verbatimEnd)
protected void print(PrintStream output, String text)
Copyright © 2003–2019. All rights reserved.