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
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
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) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
afterScenario
(Timing timing) void
void
afterScenarioSteps
(StepCollector.Stage stage, Lifecycle.ExecutionType type) void
void
afterStory
(boolean givenOrRestartingStory) void
afterStorySteps
(StepCollector.Stage stage, Lifecycle.ExecutionType type) void
void
beforeExamples
(List<String> steps, ExamplesTable table) void
void
beforeScenario
(Scenario scenario) void
void
void
beforeStep
(Step step) void
void
beforeStory
(Story story, boolean givenStory) void
beforeStorySteps
(StepCollector.Stage stage, Lifecycle.ExecutionType type) void
boolean
doCompressFailureTrace
(boolean compressFailureTrace) doReportFailureTrace
(boolean reportFailureTrace) void
dryRun()
protected Object[]
escape
(PrintStreamOutput.Format format, Object... args) Escapes args' string values according to formatvoid
void
void
failedOutcomes
(String step, OutcomesTable table) protected String
Formats event output by key, usually equal to the method name.protected String
formatTable
(ExamplesTable table) protected String
formatVerbatim
(Verbatim verbatim) void
givenStories
(List<String> storyPaths) void
givenStories
(GivenStories givenStories) void
void
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
void
notPerformed
(String step) protected void
overwritePattern
(String key, String pattern) void
protected void
print
(PrintStream output, String text) protected void
Prints text to output stream, replacing parameter start and end placeholdersboolean
void
void
restartedStory
(Story story, Throwable cause) void
scenarioExcluded
(Scenario scenario, String filter) void
storyCancelled
(Story story, StoryDuration storyDuration) void
storyExcluded
(Story story, String filter) void
successful
(String step) toString()
protected String
transformPrintingTable
(String text, String tableStart, String tableEnd) protected String
transformPrintingVerbatim
(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:
beforeStep
in interfaceStoryReporter
- Overrides:
beforeStep
in classNullStoryReporter
-
successful
- Specified by:
successful
in interfaceStoryReporter
- Overrides:
successful
in classNullStoryReporter
-
ignorable
- Specified by:
ignorable
in interfaceStoryReporter
- Overrides:
ignorable
in classNullStoryReporter
-
comment
- Specified by:
comment
in interfaceStoryReporter
- Overrides:
comment
in classNullStoryReporter
-
pending
- Specified by:
pending
in interfaceStoryReporter
- Overrides:
pending
in classNullStoryReporter
-
notPerformed
- Specified by:
notPerformed
in interfaceStoryReporter
- Overrides:
notPerformed
in classNullStoryReporter
-
failed
- Specified by:
failed
in interfaceStoryReporter
- Overrides:
failed
in classNullStoryReporter
-
failedOutcomes
- Specified by:
failedOutcomes
in interfaceStoryReporter
- Overrides:
failedOutcomes
in classNullStoryReporter
-
storyExcluded
- Specified by:
storyExcluded
in interfaceStoryReporter
- Overrides:
storyExcluded
in classNullStoryReporter
-
storyCancelled
- Specified by:
storyCancelled
in interfaceStoryReporter
- Overrides:
storyCancelled
in classNullStoryReporter
-
beforeStory
- Specified by:
beforeStory
in interfaceStoryReporter
- Overrides:
beforeStory
in classNullStoryReporter
-
beforeScenarios
public void beforeScenarios()- Specified by:
beforeScenarios
in interfaceStoryReporter
- Overrides:
beforeScenarios
in classNullStoryReporter
-
afterScenarios
public void afterScenarios()- Specified by:
afterScenarios
in interfaceStoryReporter
- Overrides:
afterScenarios
in classNullStoryReporter
-
narrative
- Specified by:
narrative
in interfaceStoryReporter
- Overrides:
narrative
in classNullStoryReporter
-
lifecycle
- Specified by:
lifecycle
in interfaceStoryReporter
- Overrides:
lifecycle
in classNullStoryReporter
-
beforeScenarioSteps
- Specified by:
beforeScenarioSteps
in interfaceStoryReporter
- Overrides:
beforeScenarioSteps
in classNullStoryReporter
-
afterScenarioSteps
- Specified by:
afterScenarioSteps
in interfaceStoryReporter
- Overrides:
afterScenarioSteps
in classNullStoryReporter
-
beforeComposedSteps
public void beforeComposedSteps()- Specified by:
beforeComposedSteps
in interfaceStoryReporter
- Overrides:
beforeComposedSteps
in classNullStoryReporter
-
afterComposedSteps
public void afterComposedSteps()- Specified by:
afterComposedSteps
in interfaceStoryReporter
- Overrides:
afterComposedSteps
in classNullStoryReporter
-
beforeStoriesSteps
- Specified by:
beforeStoriesSteps
in interfaceStoryReporter
- Overrides:
beforeStoriesSteps
in classNullStoryReporter
-
afterStoriesSteps
- Specified by:
afterStoriesSteps
in interfaceStoryReporter
- Overrides:
afterStoriesSteps
in classNullStoryReporter
-
beforeStorySteps
- Specified by:
beforeStorySteps
in interfaceStoryReporter
- Overrides:
beforeStorySteps
in classNullStoryReporter
-
afterStorySteps
- Specified by:
afterStorySteps
in interfaceStoryReporter
- Overrides:
afterStorySteps
in classNullStoryReporter
-
afterStory
public void afterStory(boolean givenOrRestartingStory) - Specified by:
afterStory
in interfaceStoryReporter
- Overrides:
afterStory
in classNullStoryReporter
-
beforeGivenStories
public void beforeGivenStories()- Specified by:
beforeGivenStories
in interfaceStoryReporter
- Overrides:
beforeGivenStories
in classNullStoryReporter
-
givenStories
- Specified by:
givenStories
in interfaceStoryReporter
- Overrides:
givenStories
in classNullStoryReporter
-
givenStories
- Specified by:
givenStories
in interfaceStoryReporter
- Overrides:
givenStories
in classNullStoryReporter
-
afterGivenStories
public void afterGivenStories()- Specified by:
afterGivenStories
in interfaceStoryReporter
- Overrides:
afterGivenStories
in classNullStoryReporter
-
scenarioExcluded
- Specified by:
scenarioExcluded
in interfaceStoryReporter
- Overrides:
scenarioExcluded
in classNullStoryReporter
-
beforeScenario
- Specified by:
beforeScenario
in interfaceStoryReporter
- Overrides:
beforeScenario
in classNullStoryReporter
-
afterScenario
- Specified by:
afterScenario
in interfaceStoryReporter
- Overrides:
afterScenario
in classNullStoryReporter
-
beforeExamples
- Specified by:
beforeExamples
in interfaceStoryReporter
- Overrides:
beforeExamples
in classNullStoryReporter
-
example
- Specified by:
example
in interfaceStoryReporter
- Overrides:
example
in classNullStoryReporter
-
afterExamples
public void afterExamples()- Specified by:
afterExamples
in interfaceStoryReporter
- Overrides:
afterExamples
in classNullStoryReporter
-
dryRun
public void dryRun()- Specified by:
dryRun
in interfaceStoryReporter
- Overrides:
dryRun
in classNullStoryReporter
-
restarted
- Specified by:
restarted
in interfaceStoryReporter
- Overrides:
restarted
in classNullStoryReporter
-
restartedStory
- Specified by:
restartedStory
in interfaceStoryReporter
- Overrides:
restartedStory
in 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
-