org.jbehave.scenario.reporters
Class ScenarioReporterBuilder
java.lang.Object
org.jbehave.scenario.reporters.ScenarioReporterBuilder
public class ScenarioReporterBuilder
- extends java.lang.Object
A Builder for
ScenarioReporter
s. It builds a DelegatingScenarioReporter
with delegates for a number of formats - mostly file-based ones except
. It requires a
FilePrintStreamFactory
and provides default delegate instances for
each format.
To build reporter with default delegates for given formats:
Class<MyScenario> scenarioClass = MyScenario.class;
ScenarioNameResolver nameResolver = new UnderscoredCamelCaseResolver();
FilePrintStreamFactory printStreamFactory = new FilePrintStreamFactory(scenarioClass, nameResolver);
ScenarioReporter reporter = new ScenarioReporterBuilder(printStreamFactory).with(HTML).with(TXT).build();
The builder is configured to build with the ScenarioReporterBuilder.Format.STATS
format by default. To change the default formats
the user can override the method:
new ScenarioReporterBuilder(printStreamFactory){
protected void withDefaultFormats() {
with(Format.STATS);
}
}
The builder configures the file-based reporters to output to the default file directory FilePrintStreamFactory.FileConfiguration.DIRECTORY
.
To change the default:
new ScenarioReporterBuilder(printStreamFactory).outputTo("my-reports").with(HTML).with(TXT).build();
The builder provides default instances for all reporters. To change the reporter for a specific instance,
e.g. to report format TXT to .text files and to inject other non-default parameters,
such as keywords for a different locale:
new ScenarioReporterBuilder(printStreamFactory){
public ScenarioReporter reporterFor(Format format){
switch (format) {
case TXT:
factory.useConfiguration(new FileConfiguration("text"));
return new PrintStreamScenarioReporter(factory.getPrintStream(), new Properties(), new I18nKeywords(Locale), true);
default:
return super.reporterFor(format);
}
}
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
factory
protected final FilePrintStreamFactory factory
delegates
protected java.util.Map<ScenarioReporterBuilder.Format,ScenarioReporter> delegates
ScenarioReporterBuilder
public ScenarioReporterBuilder(FilePrintStreamFactory factory)
withDefaultFormats
protected void withDefaultFormats()
build
public ScenarioReporter build()
outputTo
public ScenarioReporterBuilder outputTo(java.lang.String fileDirectory)
with
public ScenarioReporterBuilder with(ScenarioReporterBuilder.Format format)
reporterFor
public ScenarioReporter reporterFor(ScenarioReporterBuilder.Format format)
getDelegates
public java.util.Map<ScenarioReporterBuilder.Format,ScenarioReporter> getDelegates()
fileConfiguration
protected FilePrintStreamFactory.FileConfiguration fileConfiguration(java.lang.String extension)
Copyright © 2003-2010. All Rights Reserved.