|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jbehave.core.reporters.PrintStreamOutput
public abstract class PrintStreamOutput
Abstract story reporter that outputs to a PrintStream.
The output of the reported event is configurable via:
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 | |
---|---|
static class |
PrintStreamOutput.Format
|
Constructor Summary | |
---|---|
protected |
PrintStreamOutput(PrintStreamOutput.Format format,
PrintStream output,
Properties outputPatterns,
Keywords keywords,
boolean reportFailureTrace,
boolean compressFailureTrace)
|
Method Summary | |
---|---|
void |
afterExamples()
|
void |
afterScenario()
|
void |
afterStory(boolean givenStory)
|
void |
beforeExamples(List<String> steps,
ExamplesTable table)
|
void |
beforeScenario(String title)
|
void |
beforeStory(Story story,
boolean givenStory)
|
boolean |
compressFailureTrace()
|
PrintStreamOutput |
doCompressFailureTrace(boolean compressFailureTrace)
|
PrintStreamOutput |
doReportFailureTrace(boolean reportFailureTrace)
|
void |
dryRun()
|
protected Object[] |
escape(PrintStreamOutput.Format format,
Object... args)
Escapes args' string values according to format |
void |
example(Map<String,String> tableRow)
|
void |
failed(String step,
Throwable storyFailure)
|
void |
failedOutcomes(String step,
OutcomesTable table)
|
protected String |
format(String key,
String defaultPattern,
Object... args)
Formats event output by key, usually equal to the method name. |
protected String |
formatTable(ExamplesTable table)
|
void |
givenStories(GivenStories givenStories)
|
void |
givenStories(List<String> storyPaths)
|
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 |
narrative(Narrative narrative)
|
void |
notPerformed(String step)
|
protected void |
overwritePattern(String key,
String pattern)
|
void |
pending(String step)
|
void |
pendingMethods(List<String> methods)
|
protected void |
print(String text)
Prints text to output stream, replacing parameter start and end placeholders |
boolean |
reportFailureTrace()
|
void |
restarted(String step,
Throwable cause)
|
void |
scenarioMeta(Meta meta)
|
void |
scenarioNotAllowed(Scenario scenario,
String filter)
|
void |
storyCancelled(Story story,
StoryDuration storyDuration)
|
void |
storyNotAllowed(Story story,
String filter)
|
void |
successful(String step)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected PrintStreamOutput(PrintStreamOutput.Format format, PrintStream output, Properties outputPatterns, Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace)
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 storyFailure)
failed
in interface StoryReporter
public void failedOutcomes(String step, OutcomesTable table)
failedOutcomes
in interface StoryReporter
public void storyNotAllowed(Story story, String filter)
storyNotAllowed
in interface StoryReporter
public void storyCancelled(Story story, StoryDuration storyDuration)
storyCancelled
in interface StoryReporter
public void beforeStory(Story story, boolean givenStory)
beforeStory
in interface StoryReporter
public void narrative(Narrative narrative)
narrative
in interface StoryReporter
public void afterStory(boolean givenStory)
afterStory
in interface StoryReporter
public void givenStories(GivenStories givenStories)
givenStories
in interface StoryReporter
public void givenStories(List<String> storyPaths)
givenStories
in interface StoryReporter
public void scenarioNotAllowed(Scenario scenario, String filter)
scenarioNotAllowed
in interface StoryReporter
public void beforeScenario(String title)
beforeScenario
in interface StoryReporter
public void scenarioMeta(Meta meta)
scenarioMeta
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
public void dryRun()
dryRun
in interface StoryReporter
public void pendingMethods(List<String> methods)
pendingMethods
in interface StoryReporter
public void restarted(String step, Throwable cause)
restarted
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 String formatTable(ExamplesTable table)
protected Object[] escape(PrintStreamOutput.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(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
public boolean reportFailureTrace()
public PrintStreamOutput doReportFailureTrace(boolean reportFailureTrace)
public boolean compressFailureTrace()
public PrintStreamOutput doCompressFailureTrace(boolean compressFailureTrace)
protected void overwritePattern(String key, String pattern)
protected void print(String text)
text
- the String to printpublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |