Package org.jbehave.core.reporters
Class PrintStreamOutput
java.lang.Object
org.jbehave.core.reporters.NullStoryReporter
org.jbehave.core.reporters.PrintStreamOutput
- All Implemented Interfaces:
StoryReporter
- Direct Known Subclasses:
HtmlOutput,JsonOutput,TxtOutput,XmlOutput
Abstract story reporter that outputs to a PrintStream.
The output of the reported event is configurable via:
- custom output patterns, providing only the patterns that differ from default
- keywords localised for different languages, providing the formatOutcome Locale
- flag to report failure trace
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"));
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties defaultPatterns, Properties outputPatterns, Keywords keywords) protectedPrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties defaultPatterns, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace) protectedPrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidafterScenario(Timing timing) voidvoidafterScenarioSteps(StepCollector.Stage stage, Lifecycle.ExecutionType type) voidvoidafterStory(boolean givenOrRestartingStory) voidafterStorySteps(StepCollector.Stage stage, Lifecycle.ExecutionType type) voidvoidbeforeExamples(List<String> steps, ExamplesTable table) voidvoidbeforeScenario(Scenario scenario) voidvoidvoidbeforeStep(Step step) voidvoidbeforeStory(Story story, boolean givenStory) voidbeforeStorySteps(StepCollector.Stage stage, Lifecycle.ExecutionType type) voidbooleandoCompressFailureTrace(boolean compressFailureTrace) doReportFailureTrace(boolean reportFailureTrace) voiddryRun()protected Object[]escape(PrintStreamOutput.Format format, Object... args) Escapes args' string values according to formatvoidvoidvoidfailedOutcomes(String step, OutcomesTable table) protected StringFormats event output by key, usually equal to the method name.protected StringformatTable(ExamplesTable table) protected StringformatVerbatim(Verbatim verbatim) voidgivenStories(List<String> storyPaths) voidgivenStories(GivenStories givenStories) voidvoidprotected StringlookupPattern(String key, String defaultPattern) Looks up the format pattern for the event output by key, conventionally equal to the method name.voidvoidnotPerformed(String step) protected voidoverwritePattern(String key, String pattern) voidprotected voidprint(PrintStream output, String text) protected voidPrints text to output stream, replacing parameter start and end placeholdersbooleanvoidvoidrestartedStory(Story story, Throwable cause) voidscenarioExcluded(Scenario scenario, String filter) voidstoryCancelled(Story story, StoryDuration storyDuration) voidstoryExcluded(Story story, String filter) voidsuccessful(String step) toString()protected StringtransformPrintingTable(String text, String tableStart, String tableEnd) protected StringtransformPrintingVerbatim(String text, String verbatimStart, String verbatimEnd) Methods inherited from class org.jbehave.core.reporters.NullStoryReporter
pending, pendingMethods
-
Field Details
-
NL
- See Also:
-
-
Constructor Details
-
PrintStreamOutput
protected PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties defaultPatterns, Properties outputPatterns, Keywords keywords) -
PrintStreamOutput
protected PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties defaultPatterns, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace) -
PrintStreamOutput
protected PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace)
-
-
Method Details
-
beforeStep
- Specified by:
beforeStepin interfaceStoryReporter- Overrides:
beforeStepin classNullStoryReporter
-
successful
- Specified by:
successfulin interfaceStoryReporter- Overrides:
successfulin classNullStoryReporter
-
ignorable
- Specified by:
ignorablein interfaceStoryReporter- Overrides:
ignorablein classNullStoryReporter
-
comment
- Specified by:
commentin interfaceStoryReporter- Overrides:
commentin classNullStoryReporter
-
pending
- Specified by:
pendingin interfaceStoryReporter- Overrides:
pendingin classNullStoryReporter
-
notPerformed
- Specified by:
notPerformedin interfaceStoryReporter- Overrides:
notPerformedin classNullStoryReporter
-
failed
- Specified by:
failedin interfaceStoryReporter- Overrides:
failedin classNullStoryReporter
-
failedOutcomes
- Specified by:
failedOutcomesin interfaceStoryReporter- Overrides:
failedOutcomesin classNullStoryReporter
-
storyExcluded
- Specified by:
storyExcludedin interfaceStoryReporter- Overrides:
storyExcludedin classNullStoryReporter
-
storyCancelled
- Specified by:
storyCancelledin interfaceStoryReporter- Overrides:
storyCancelledin classNullStoryReporter
-
beforeStory
- Specified by:
beforeStoryin interfaceStoryReporter- Overrides:
beforeStoryin classNullStoryReporter
-
beforeScenarios
public void beforeScenarios()- Specified by:
beforeScenariosin interfaceStoryReporter- Overrides:
beforeScenariosin classNullStoryReporter
-
afterScenarios
public void afterScenarios()- Specified by:
afterScenariosin interfaceStoryReporter- Overrides:
afterScenariosin classNullStoryReporter
-
narrative
- Specified by:
narrativein interfaceStoryReporter- Overrides:
narrativein classNullStoryReporter
-
lifecycle
- Specified by:
lifecyclein interfaceStoryReporter- Overrides:
lifecyclein classNullStoryReporter
-
beforeScenarioSteps
- Specified by:
beforeScenarioStepsin interfaceStoryReporter- Overrides:
beforeScenarioStepsin classNullStoryReporter
-
afterScenarioSteps
- Specified by:
afterScenarioStepsin interfaceStoryReporter- Overrides:
afterScenarioStepsin classNullStoryReporter
-
beforeComposedSteps
public void beforeComposedSteps()- Specified by:
beforeComposedStepsin interfaceStoryReporter- Overrides:
beforeComposedStepsin classNullStoryReporter
-
afterComposedSteps
public void afterComposedSteps()- Specified by:
afterComposedStepsin interfaceStoryReporter- Overrides:
afterComposedStepsin classNullStoryReporter
-
beforeStoriesSteps
- Specified by:
beforeStoriesStepsin interfaceStoryReporter- Overrides:
beforeStoriesStepsin classNullStoryReporter
-
afterStoriesSteps
- Specified by:
afterStoriesStepsin interfaceStoryReporter- Overrides:
afterStoriesStepsin classNullStoryReporter
-
beforeStorySteps
- Specified by:
beforeStoryStepsin interfaceStoryReporter- Overrides:
beforeStoryStepsin classNullStoryReporter
-
afterStorySteps
- Specified by:
afterStoryStepsin interfaceStoryReporter- Overrides:
afterStoryStepsin classNullStoryReporter
-
afterStory
public void afterStory(boolean givenOrRestartingStory) - Specified by:
afterStoryin interfaceStoryReporter- Overrides:
afterStoryin classNullStoryReporter
-
beforeGivenStories
public void beforeGivenStories()- Specified by:
beforeGivenStoriesin interfaceStoryReporter- Overrides:
beforeGivenStoriesin classNullStoryReporter
-
givenStories
- Specified by:
givenStoriesin interfaceStoryReporter- Overrides:
givenStoriesin classNullStoryReporter
-
givenStories
- Specified by:
givenStoriesin interfaceStoryReporter- Overrides:
givenStoriesin classNullStoryReporter
-
afterGivenStories
public void afterGivenStories()- Specified by:
afterGivenStoriesin interfaceStoryReporter- Overrides:
afterGivenStoriesin classNullStoryReporter
-
scenarioExcluded
- Specified by:
scenarioExcludedin interfaceStoryReporter- Overrides:
scenarioExcludedin classNullStoryReporter
-
beforeScenario
- Specified by:
beforeScenarioin interfaceStoryReporter- Overrides:
beforeScenarioin classNullStoryReporter
-
afterScenario
- Specified by:
afterScenarioin interfaceStoryReporter- Overrides:
afterScenarioin classNullStoryReporter
-
beforeExamples
- Specified by:
beforeExamplesin interfaceStoryReporter- Overrides:
beforeExamplesin classNullStoryReporter
-
example
- Specified by:
examplein interfaceStoryReporter- Overrides:
examplein classNullStoryReporter
-
afterExamples
public void afterExamples()- Specified by:
afterExamplesin interfaceStoryReporter- Overrides:
afterExamplesin classNullStoryReporter
-
dryRun
public void dryRun()- Specified by:
dryRunin interfaceStoryReporter- Overrides:
dryRunin classNullStoryReporter
-
restarted
- Specified by:
restartedin interfaceStoryReporter- Overrides:
restartedin classNullStoryReporter
-
restartedStory
- Specified by:
restartedStoryin interfaceStoryReporter- Overrides:
restartedStoryin classNullStoryReporter
-
format
Formats event output by key, usually equal to the method name.- Parameters:
key- the event keydefaultPattern- the default pattern to return if a custom pattern is not foundargs- the args used to format output- Returns:
- A formatted event output
-
formatTable
-
formatVerbatim
-
escape
Escapes args' string values according to format- Parameters:
format- the Format used by the PrintStreamargs- the array of args to escape- Returns:
- The cloned and escaped array of args
-
lookupPattern
Looks up the format pattern for the event output by key, conventionally equal to the method name. The pattern is used by the {#format(String,String,Object...)} method and by default is formatted using theMessageFormat.format(String, Object...)method. If no pattern is found for key or needs to be overridden, the default pattern should be returned.- Parameters:
key- the format pattern keydefaultPattern- the default pattern if no pattern is- Returns:
- The format patter for the given key
-
reportFailureTrace
public boolean reportFailureTrace() -
doReportFailureTrace
-
compressFailureTrace
public boolean compressFailureTrace() -
doCompressFailureTrace
-
overwritePattern
-
print
Prints text to output stream, replacing parameter start and end placeholders- Parameters:
text- the String to print
-
print
-
transformPrintingTable
-
transformPrintingVerbatim
-
toString
-