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