|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jbehave.core.reporters.PrintStreamStoryReporter
public class PrintStreamStoryReporter
Scenario reporter that outputs to a PrintStream, defaulting to System.out.
The output of the reported event is also configurable via two other means:
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()
and
#lookupPattern()
methods are overrideable 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 I18nKeyWords
using the appropriate Locale
, e.g.
KeyWords keywords = new I18nKeyWords(new Locale("it");
Nested Class Summary | |
---|---|
static class |
PrintStreamStoryReporter.Format
|
Field Summary | |
---|---|
protected PrintStream |
output
|
Constructor Summary | |
---|---|
PrintStreamStoryReporter()
|
|
PrintStreamStoryReporter(KeyWords keywords)
|
|
PrintStreamStoryReporter(PrintStream output)
|
|
PrintStreamStoryReporter(PrintStream output,
Properties outputPatterns,
KeyWords keywords,
boolean reportErrors)
|
|
PrintStreamStoryReporter(PrintStream output,
Properties outputPatterns,
PrintStreamStoryReporter.Format format,
KeyWords keywords,
boolean reportErrors)
|
|
PrintStreamStoryReporter(Properties outputPatterns)
|
|
PrintStreamStoryReporter(Properties outputPatterns,
PrintStreamStoryReporter.Format format)
|
Method Summary | |
---|---|
void |
afterExamples()
|
void |
afterScenario()
|
void |
afterStory(boolean embeddedStory)
|
void |
beforeExamples(List<String> steps,
ExamplesTable table)
|
void |
beforeScenario(String title)
|
void |
beforeStory(Story story,
boolean embeddedStory)
|
protected Object[] |
escape(PrintStreamStoryReporter.Format format,
Object... args)
Escapes args' string values according to format |
void |
example(Map<String,String> tableRow)
|
void |
failed(String step,
Throwable cause)
|
protected String |
format(String key,
String defaultPattern,
Object... args)
Formats event output by key, usually equal to the method name. |
void |
givenStories(List<String> givenScenarios)
|
void |
ignorable(String step)
|
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 |
notPerformed(String step)
|
void |
pending(String step)
|
protected void |
print(String text)
Prints text to output stream, replacing parameter start and end placeholders |
void |
successful(String step)
|
protected void |
usePrintStream(PrintStream output)
Changes print stream used for output |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected PrintStream output
Constructor Detail |
---|
public PrintStreamStoryReporter()
public PrintStreamStoryReporter(PrintStream output)
public PrintStreamStoryReporter(Properties outputPatterns)
public PrintStreamStoryReporter(Properties outputPatterns, PrintStreamStoryReporter.Format format)
public PrintStreamStoryReporter(KeyWords keywords)
public PrintStreamStoryReporter(PrintStream output, Properties outputPatterns, KeyWords keywords, boolean reportErrors)
public PrintStreamStoryReporter(PrintStream output, Properties outputPatterns, PrintStreamStoryReporter.Format format, KeyWords keywords, boolean reportErrors)
Method Detail |
---|
public void successful(String step)
successful
in interface StoryReporter
public void ignorable(String step)
ignorable
in interface StoryReporter
public void pending(String step)
pending
in interface StoryReporter
public void notPerformed(String step)
notPerformed
in interface StoryReporter
public void failed(String step, Throwable cause)
failed
in interface StoryReporter
public void beforeStory(Story story, boolean embeddedStory)
beforeStory
in interface StoryReporter
public void afterStory(boolean embeddedStory)
afterStory
in interface StoryReporter
public void givenStories(List<String> givenScenarios)
givenStories
in interface StoryReporter
public void beforeScenario(String title)
beforeScenario
in interface StoryReporter
public void afterScenario()
afterScenario
in interface StoryReporter
public void beforeExamples(List<String> steps, ExamplesTable table)
beforeExamples
in interface StoryReporter
public void example(Map<String,String> tableRow)
example
in interface StoryReporter
public void afterExamples()
afterExamples
in interface StoryReporter
protected 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 output
protected Object[] escape(PrintStreamStoryReporter.Format format, Object... args)
format
- the Format used by the PrintStreamargs
- the array of args to escape
protected String lookupPattern(String key, String defaultPattern)
MessageFormat#format()
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 is
protected void usePrintStream(PrintStream output)
output
- the new PrintStream to useprotected void print(String text)
text
- the String to print
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |