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

public abstract class PrintStreamOutput extends NullStoryReporter

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"));