- Revision
- 1614
- Author
- mauro
- Date
- 2010-04-21 13:11:27 -0500 (Wed, 21 Apr 2010)
Log Message
JBEHAVE-276: Updated reports configuration and documentation.
Modified Paths
Diff
Modified: trunk/core/distribution/src/site/content/reports.html (1613 => 1614)
--- trunk/core/distribution/src/site/content/reports.html 2010-04-14 23:15:17 UTC (rev 1613) +++ trunk/core/distribution/src/site/content/reports.html 2010-04-21 18:11:27 UTC (rev 1614) @@ -42,29 +42,41 @@ reporter (both to <b>System.out</b> and to a file) and an HTML reporter to a file:</p> <pre class="brush: java"> - private static ScenarioNameResolver converter = new UnderscoredCamelCaseResolver(".scenario"); - public TraderScenario(final Class scenarioClass) { - super(new PropertyBasedConfiguration() { + final ScenarioNameResolver resolver = new UnderscoredCamelCaseResolver(".scenario"); + useConfiguration(new MostUsefulConfiguration() { @Override public ScenarioDefiner forDefiningScenarios() { - return new ClasspathScenarioDefiner(converter, new PatternScenarioParser(this)); + return new ClasspathScenarioDefiner(resolver, new PatternScenarioParser(keywords())); } - + @Override public ScenarioReporter forReportingScenarios() { - return new ScenarioReporterBuilder(new FilePrintStreamFactory(scenarioClass, converter)) - .with(CONSOLE) // report to System.out - .with(TXT) // report to .txt file in PLAIN format - .with(HTML) // report to .html file in HTML format - .with(XML) // report to .xml file in XML format + return new ScenarioReporterBuilder(new FilePrintStreamFactory(scenarioClass, resolver)) + .with(CONSOLE) + .with(TXT) + .with(HTML) + .with(XML) .build(); } - }, new TraderSteps()); + }); + + StepsConfiguration configuration = new StepsConfiguration(); + addSteps(createSteps(configuration)); } + + protected CandidateSteps[] createSteps(StepsConfiguration configuration) { + return new StepsFactory(configuration).createCandidateSteps(new TraderSteps(new TradingService()), new BeforeAfterSteps()); + } </pre> +<span class="followup">For a fully-working example of reporting configuration you may consult the +<a href="" example</a>. Note that the configuration only needs + to be done in one place, i.e. the parent Scenario class, and not repeated in every Scenario class that maps to a + textual scenario. +</span> + <p>Note that we use the <a href="" to implement a builder pattern for file-based reporters via the <a
Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java (1613 => 1614)
--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java 2010-04-14 23:15:17 UTC (rev 1613) +++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java 2010-04-21 18:11:27 UTC (rev 1614) @@ -12,7 +12,7 @@ import org.jbehave.examples.trader.persistence.TraderPersister; import org.jbehave.examples.trader.service.TradingService; import org.jbehave.scenario.JUnitScenario; -import org.jbehave.scenario.PropertyBasedConfiguration; +import org.jbehave.scenario.MostUsefulConfiguration; import org.jbehave.scenario.RunnableScenario; import org.jbehave.scenario.parser.ClasspathScenarioDefiner; import org.jbehave.scenario.parser.PatternScenarioParser; @@ -30,12 +30,11 @@ import org.jbehave.scenario.steps.StepsConfiguration; import org.jbehave.scenario.steps.StepsFactory; -public class TraderScenario extends JUnitScenario { +public abstract class TraderScenario extends JUnitScenario { - private static ScenarioNameResolver resolver = new UnderscoredCamelCaseResolver(".scenario"); - public TraderScenario(final Class<? extends RunnableScenario> scenarioClass) { - super(new PropertyBasedConfiguration() { + final ScenarioNameResolver resolver = new UnderscoredCamelCaseResolver(".scenario"); + useConfiguration(new MostUsefulConfiguration() { @Override public ScenarioDefiner forDefiningScenarios() { return new ClasspathScenarioDefiner(resolver, new PatternScenarioParser(keywords()));
To unsubscribe from this list please visit: