- Revision
- 1386
- Author
- mauro
- Date
- 2009-11-25 03:02:20 -0600 (Wed, 25 Nov 2009)
Log Message
JBEHAVE-161: Start of HTML-based reporter. Added CollectingScenarioReporter contributed by Mirko Friedenhagen. Added HtmlPrintStreamScenarioReporter which extends PrintStreamScenarioReporter.
Modified Paths
- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java
- trunk/core/jbehave-core/pom.xml
- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java
- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java
Added Paths
Diff
Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java (1385 => 1386)
--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -6,6 +6,9 @@ import org.jbehave.scenario.parser.PatternScenarioParser; import org.jbehave.scenario.parser.ScenarioDefiner; import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver; +import org.jbehave.scenario.reporters.CollectingScenarioReporter; +import org.jbehave.scenario.reporters.FilePrintStreamFactory; +import org.jbehave.scenario.reporters.HtmlPrintStreamScenarioReporter; import org.jbehave.scenario.reporters.PrintStreamScenarioReporter; import org.jbehave.scenario.reporters.ScenarioReporter; @@ -21,7 +24,7 @@ @Override public ScenarioReporter forReportingScenarios() { - return new PrintStreamScenarioReporter(); + return new CollectingScenarioReporter(new PrintStreamScenarioReporter(), new HtmlPrintStreamScenarioReporter(new FilePrintStreamFactory().createPrintStream("index"))); } }, new TraderSteps());
Modified: trunk/core/jbehave-core/pom.xml (1385 => 1386)
--- trunk/core/jbehave-core/pom.xml 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/jbehave-core/pom.xml 2009-11-25 09:02:20 UTC (rev 1386) @@ -16,6 +16,11 @@ <artifactId>ant</artifactId> </dependency> <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.4</version> + </dependency> + <dependency> <groupId>com.thoughtworks.paranamer</groupId> <artifactId>paranamer</artifactId> <version>2.1</version>
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java (1385 => 1386)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -74,7 +74,7 @@ // Then InOrder inOrder = inOrder(reporter, errorStrategy); - inOrder.verify(reporter).beforeStory(storyDefinition.getBlurb()); + inOrder.verify(reporter).beforeStory(storyDefinition); inOrder.verify(reporter).beforeScenario("my title 1"); inOrder.verify(reporter).failed("failingStep", anException); inOrder.verify(reporter).notPerformed("successfulStep"); @@ -127,12 +127,12 @@ // Then InOrder inOrder = inOrder(reporter); - inOrder.verify(reporter).beforeStory(storyDefinition2.getBlurb()); + inOrder.verify(reporter).beforeStory(storyDefinition2); inOrder.verify(reporter).givenScenarios(givenScenarios); inOrder.verify(reporter).successful("successfulStep"); inOrder.verify(reporter).successful("anotherSuccessfulStep"); inOrder.verify(reporter).afterStory(); - verify(reporter, never()).beforeStory(storyDefinition1.getBlurb()); + verify(reporter, never()).beforeStory(storyDefinition1); } @Test @@ -196,7 +196,7 @@ verify(secondStepNotPerformed).doNotPerform(); InOrder inOrder = inOrder(reporter, errorStrategy); - inOrder.verify(reporter).beforeStory((Blurb) anyObject()); + inOrder.verify(reporter).beforeStory((StoryDefinition) anyObject()); inOrder.verify(reporter).beforeScenario((String) anyObject()); inOrder.verify(reporter).failed("When I fail", failure.getThrowable()); inOrder.verify(reporter).notPerformed("Then I should not be performed");
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java (1385 => 1386)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -51,13 +51,13 @@ reporter.afterScenario(); ensureThat(out.toString(), equalTo( - "Scenario: A title" + NL + NL + + "Scenario: A title" + NL + "Given I have a balance of $50" + NL + "When I request $20" + NL + "When I ask Liz for a loan of $100 (FAILED)" + NL + "Then I should have a balance of $30 (PENDING)" + NL + - "Then I should have $20 (NOT PERFORMED)" + NL + NL + - stackTrace + NL)); + "Then I should have $20 (NOT PERFORMED)" + NL + + NL + stackTrace + NL)); out = new ByteArrayOutputStream(); reporter = new PrintStreamScenarioReporter(new PrintStream(out)); @@ -78,9 +78,9 @@ IllegalAccessException exception = new IllegalAccessException("Leave my money alone!"); ByteArrayOutputStream out = new ByteArrayOutputStream(); Properties patterns = new Properties(); - patterns.setProperty("pending", "{0} - {1} - need to implement me"); - patterns.setProperty("failed", "{0} <<< {1}"); - patterns.setProperty("notPerformed", "{0} : {1} (because of previous pending)"); + patterns.setProperty("pending", "{0} - {1} - need to implement me\n"); + patterns.setProperty("failed", "{0} <<< {1}\n"); + patterns.setProperty("notPerformed", "{0} : {1} (because of previous pending)\n"); ScenarioReporter reporter = new PrintStreamScenarioReporter(new PrintStream(out), patterns, new I18nKeyWords(), true); reporter.successful("Given I have a balance of $50");
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java (1385 => 1386)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -53,7 +53,7 @@ throwable = null; if ( !embeddedStory ){ - reporter.beforeStory(story.getBlurb()); + reporter.beforeStory(story); } for (ScenarioDefinition scenario : story.getScenarios()) { reporter.beforeScenario(scenario.getTitle());
Added: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/CollectingScenarioReporter.java (0 => 1386)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/CollectingScenarioReporter.java (rev 0) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/CollectingScenarioReporter.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -0,0 +1,115 @@ +package org.jbehave.scenario.reporters; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.jbehave.scenario.definition.Blurb; +import org.jbehave.scenario.definition.ExamplesTable; +import org.jbehave.scenario.definition.StoryDefinition; +import org.jbehave.scenario.reporters.ScenarioReporter; + +/** + * Reporter which collects other {...@link ScenarioReporter}s and delegates all invocations to the collected reporters. + * + * @author Mirko FriedenHagen + */ +public class CollectingScenarioReporter implements ScenarioReporter { + + private final Collection<ScenarioReporter> reporters; + + /** + * Initializes this reporter with a collection of reporters. + * + * @param scenarioReporters + * the reporters to iterate over. + */ + public CollectingScenarioReporter(final Collection<ScenarioReporter> scenarioReporters) { + this.reporters = scenarioReporters; + } + + /** + * Initializes this reporter with an array of reporters. + * + * @param scenarioReporters + * the reporters to iterate over. + */ + public CollectingScenarioReporter(final ScenarioReporter... scenarioReporters) { + this(Arrays.asList(scenarioReporters)); + } + + public void afterScenario() { + for (ScenarioReporter reporter : reporters) { + reporter.afterScenario(); + } + } + + public void afterStory() { + for (ScenarioReporter reporter : reporters) { + reporter.afterStory(); + } + } + + public void beforeScenario(String title) { + for (ScenarioReporter reporter : reporters) { + reporter.beforeScenario(title); + } + } + + public void beforeStory(StoryDefinition story) { + beforeStory(story.getBlurb()); + } + + public void beforeStory(Blurb blurb) { + for (ScenarioReporter reporter : reporters) { + reporter.beforeStory(blurb); + } + } + + public void examplesTable(ExamplesTable table) { + for (ScenarioReporter reporter : reporters) { + reporter.examplesTable(table); + } + } + + public void examplesTableRow(Map<String, String> tableRow) { + for (ScenarioReporter reporter : reporters) { + reporter.examplesTableRow(tableRow); + } + } + + public void failed(String step, Throwable e) { + for (ScenarioReporter reporter : reporters) { + reporter.failed(step, e); + } + } + + public void givenScenarios(List<String> givenScenarios) { + for (ScenarioReporter reporter : reporters) { + reporter.givenScenarios(givenScenarios); + } + } + + public void notPerformed(String step) { + for (ScenarioReporter reporter : reporters) { + reporter.notPerformed(step); + } + } + + public void pending(String step) { + for (ScenarioReporter reporter : reporters) { + reporter.pending(step); + } + } + + public void successful(String step) { + for (ScenarioReporter reporter : reporters) { + reporter.successful(step); + } + } + + public Collection<ScenarioReporter> getScenarioReporters() { + return reporters; + } +}
Added: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/FilePrintStreamFactory.java (0 => 1386)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/FilePrintStreamFactory.java (rev 0) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/FilePrintStreamFactory.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -0,0 +1,46 @@ +package org.jbehave.scenario.reporters; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintStream; + +import org.jbehave.scenario.RunnableScenario; + +/** + * Creates {...@link PrintStream} instance that write to a file. It also provides useful + * defaults for reporting scenarios. + */ +public class FilePrintStreamFactory { + + private static final File DIR = new File("target", "scenario-reports"); + private static final String HTML = "html"; + private final File dir; + private final String extension; + + public FilePrintStreamFactory() { + this(DIR, HTML); + } + + public FilePrintStreamFactory(File dir, String extension) { + this.dir = dir; + this.extension = extension; + } + + public PrintStream createPrintStream(Class<? extends RunnableScenario> scenarioClass) { + return createPrintStream(scenarioClass.getSimpleName()); + } + + public PrintStream createPrintStream(String scenarioName) { + try { + return new PrintStream(streamFile(dir, scenarioName, extension)); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } + + private static File streamFile(File dir, String fileName, String extension) { + dir.mkdirs(); + return new File(dir, fileName + "." + extension); + } + +}
Added: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java (0 => 1386)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java (rev 0) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -0,0 +1,127 @@ +package org.jbehave.scenario.reporters; + +import static org.apache.commons.lang.StringEscapeUtils.escapeHtml; + +import java.io.PrintStream; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import org.jbehave.scenario.definition.Blurb; +import org.jbehave.scenario.definition.ExamplesTable; +import org.jbehave.scenario.definition.KeyWords; +import org.jbehave.scenario.definition.StoryDefinition; + +/** + * <p> + * Scenario reporter that outputs to a PrintStream, as HTML. It extends + * {...@link PrintStreamScenarioReporter}, providing HTML-based default output + * patterns, which can be overridden via the {...@link + * HtmlPrintStreamScenarioReporter(Properties)} constructor. + * </p> + * + * @author Mirko FriedenHagen + * @author Mauro Talevi + */ +public class HtmlPrintStreamScenarioReporter extends PrintStreamScenarioReporter { + + public HtmlPrintStreamScenarioReporter() { + super(); + } + + public HtmlPrintStreamScenarioReporter(KeyWords keywords) { + super(keywords); + } + + public HtmlPrintStreamScenarioReporter(PrintStream output) { + super(output); + } + + public HtmlPrintStreamScenarioReporter(Properties outputPatterns) { + super(outputPatterns); + } + + public HtmlPrintStreamScenarioReporter(PrintStream output, Properties outputPatterns, KeyWords keywords, + boolean reportErrors) { + super(output, outputPatterns, keywords, reportErrors); + } + + public void successful(String step) { + String defaultPattern = "<li class=\"step\"><span class=\"step.successful\"><span class=\"step.text\">{0}</span></span></li>\n"; + output.print(format("successful.html", defaultPattern, escapeHtml(step))); + } + + public void pending(String step) { + String defaultPattern = "<li class=\"step\"><span class=\"step.pending\"><span class=\"step.text\">{0}</span> - {1}</span></li>\n"; + output.print(format("pending.html", defaultPattern, escapeHtml(step), keywords.pending())); + } + + public void notPerformed(String step) { + String defaultPattern = "<li class=\"step\"><span class=\"step.notPerformed\"><span class=\"step.text\">{0}</span> - {1}</span></li>\n"; + output.print(format("pending.html", defaultPattern, escapeHtml(step), keywords.notPerformed())); + } + + public void failed(String step, Throwable cause) { + this.cause = cause; + String defaultPattern = "<li class=\"step\"><span class=\"step.failed\">" + + "<span class=\"step.text\">{0}</span> - {1} </span>\n"; + output.print(format("failed.html", defaultPattern, escapeHtml(step), keywords.failed())); + } + + public void beforeStory(StoryDefinition story) { + beforeStory(story.getBlurb()); + } + + public void beforeStory(Blurb blurb) { + String defaultPattern = "<html>\n<head>\n<title>{0}</title>\n</head>\n<body>\n<h1 class=\"story\">{0}</h1>\n"; + output.print(format("beforeStory.html", defaultPattern, blurb.asString())); + } + + public void beforeScenario(String title) { + cause = null; + String defaultPattern = "<h2>{0} {1}</h2>\n<ol title=\"{1}\" class=\"scenario\">\n"; + output.print(format("beforeScenario.html", defaultPattern, keywords.scenario(), escapeHtml(title))); + } + + public void afterScenario() { + output.print(format("afterScenario.html", "</ol>\n")); + } + + public void afterStory() { + output.print(format("afterStory.html", "<body>\n</html>\n")); + } + + public void givenScenarios(List<String> givenScenarios) { + String defaultPattern = "<span class=\"givenScenarios\">{0} {1}</span>\n"; + output.print(format("givenScenarios.html", defaultPattern, keywords.givenScenarios(), escapeHtml(givenScenarios.toString()))); + } + + public void examplesTable(ExamplesTable table) { + String defaultPattern = "<h3 class=\"examplesTable\">{0}</h3>\n<table class=\"examplesTable\">\n"; + output.print(format("examplesTable.html", defaultPattern, keywords.examplesTable())); + final List<Map<String, String>> rows = table.getRows(); + final Set<String> columnNames = rows.get(0).keySet(); + output.println("<thead>\n<tr>"); + for (String columnName : columnNames) { + output.printf("<th>%s</th>", escapeHtml(columnName)); + } + output.println("</tr>\n</thead>"); + output.println("<tbody>"); + for (Map<String, String> row : rows) { + output.println("<tr>"); + for (String columnName : columnNames) { + output.printf("<td>%s</td>", escapeHtml(row.get(columnName))); + } + output.println("</tr>"); + } + output.println("</tbody>"); + output.println("</table>"); + } + + public void examplesTableRow(Map<String, String> tableRow) { + String defaultPattern = "\n<h3 class=\"examplesTableRow\">{0} {1}</h3>\n"; + output.print(format("examplesTableRow.html", defaultPattern, keywords.examplesTableRow(), escapeHtml(tableRow.toString()))); + } + +}
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java (1385 => 1386)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -6,6 +6,7 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.definition.ExamplesTable; +import org.jbehave.scenario.definition.StoryDefinition; /** * Swallows the reports from all scenarios that pass, providing output only for @@ -27,6 +28,10 @@ afterStoryState.report(); } + public void beforeStory(StoryDefinition story) { + beforeStory(story.getBlurb()); + } + public void beforeStory(final Blurb blurb) { beforeStoryState = new State() { public void report() {
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java (1385 => 1386)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -3,12 +3,14 @@ import java.io.PrintStream; import java.text.MessageFormat; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Properties; import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.definition.ExamplesTable; import org.jbehave.scenario.definition.KeyWords; +import org.jbehave.scenario.definition.StoryDefinition; import org.jbehave.scenario.i18n.I18nKeyWords; /** @@ -18,7 +20,8 @@ * <p> * The output of the reported event is also configurable via two other means: * <ul> - * <li>custom output patterns, providing only the patterns that differ from default</li> + * <li>custom output patterns, providing only the patterns that differ from + * default</li> * <li>keywords in different languages, providing the i18n locale</li> * </ul> * </p> @@ -51,126 +54,120 @@ */ public class PrintStreamScenarioReporter implements ScenarioReporter { - private final PrintStream output; - private final Properties outputPatterns; - private final KeyWords keywords; - private final boolean reportErrors; - private Throwable cause; + protected final PrintStream output; + protected final Properties outputPatterns; + protected final KeyWords keywords; + protected final boolean reportErrors; + protected Throwable cause; - public PrintStreamScenarioReporter() { - this(System.out); - } + public PrintStreamScenarioReporter() { + this(System.out); + } - public PrintStreamScenarioReporter(PrintStream output) { - this(output, new Properties(), new I18nKeyWords(), false); - } + public PrintStreamScenarioReporter(PrintStream output) { + this(output, new Properties(), new I18nKeyWords(), false); + } - public PrintStreamScenarioReporter(Properties outputPatterns) { - this(System.out, outputPatterns, new I18nKeyWords(), false); - } + public PrintStreamScenarioReporter(Properties outputPatterns) { + this(System.out, outputPatterns, new I18nKeyWords(), false); + } - public PrintStreamScenarioReporter(KeyWords keywords) { - this(System.out, new Properties(), keywords, false); - } + public PrintStreamScenarioReporter(KeyWords keywords) { + this(System.out, new Properties(), keywords, false); + } - public PrintStreamScenarioReporter(PrintStream output, - Properties outputPatterns, KeyWords keywords, boolean reportErrors) { - this.output = output; - this.outputPatterns = outputPatterns; - this.keywords = keywords; - this.reportErrors = reportErrors; - } + public PrintStreamScenarioReporter(PrintStream output, Properties outputPatterns, KeyWords keywords, + boolean reportErrors) { + this.output = output; + this.outputPatterns = outputPatterns; + this.keywords = keywords; + this.reportErrors = reportErrors; + } - public void successful(String step) { - output.println(format("successful", "{0}", step)); - } + public void successful(String step) { + output.print(format("successful", "{0}\n", step)); + } - public void pending(String step) { - output.println(format("pending", "{0} ({1})", step, keywords - .pending())); - } + public void pending(String step) { + output.print(format("pending", "{0} ({1})\n", step, keywords.pending())); + } - public void notPerformed(String step) { - output.println(format("notPerformed", "{0} ({1})", step, keywords - .notPerformed())); - } + public void notPerformed(String step) { + output.print(format("notPerformed", "{0} ({1})\n", step, keywords.notPerformed())); + } - public void failed(String step, Throwable cause) { - this.cause = cause; - output.println(format("failed", "{0} ({1})", step, keywords.failed())); - } + public void failed(String step, Throwable cause) { + this.cause = cause; + output.print(format("failed", "{0} ({1})\n", step, keywords.failed())); + } - public void afterScenario() { - output.println(); - if (reportErrors && cause != null) { - cause.printStackTrace(output); - output.println(); - } - } + public void afterScenario() { + output.println(); + if (reportErrors && cause != null) { + cause.printStackTrace(output); + output.println(); + } + } - public void beforeScenario(String title) { - cause = null; - output.println(format("beforeScenario", "{0} {1}\n", keywords - .scenario(), title)); - } + public void beforeScenario(String title) { + cause = null; + output.print(format("beforeScenario", "{0} {1}\n", keywords.scenario(), title)); + } - public void afterStory() { - output.println(format("afterStory", "")); - } + public void afterStory() { + output.print(format("afterStory", "\n")); + } - public void beforeStory(Blurb blurb) { - output.println(format("beforeStory", "{0}", blurb.asString())); - } + public void beforeStory(StoryDefinition story) { + beforeStory(story.getBlurb()); + } - public void givenScenarios(List<String> givenScenarios) { - output.println(format("givenScenarios", "{0} {1}\n", keywords - .givenScenarios(), givenScenarios)); - } + public void beforeStory(Blurb blurb) { + output.print(format("beforeStory", "{0}\n", blurb.asString())); + } - public void examplesTable(ExamplesTable table) { - output.println(format("examplesTable", "{0}\n\n{1}\n\n", keywords - .examplesTable(), table)); - } + public void givenScenarios(List<String> givenScenarios) { + output.print(format("givenScenarios", "{0} {1}\n", keywords.givenScenarios(), givenScenarios)); + } - public void examplesTableRow(Map<String, String> tableRow) { - output.println(format("examplesTableRow", "\n{0} {1}\n", keywords - .examplesTableRow(), tableRow)); - } + public void examplesTable(ExamplesTable table) { + output.print(format("examplesTable", "{0}\n\n{1}\n\n", keywords.examplesTable(), table)); + } - /** - * Formats event output by key, conventionally equal to the method name. - * - * @param key - * the event key - * @param defaultPattern - * the default pattern to return if a custom pattern is not found - * @param args - * the args used to format output - * @return A formatted event output - */ - protected String format(String key, String defaultPattern, Object... args) { - return MessageFormat.format(lookupPattern(key, defaultPattern), args); - } + public void examplesTableRow(Map<String, String> tableRow) { + output.print(format("examplesTableRow", "\n{0} {1}\n", keywords.examplesTableRow(), tableRow)); + } - /** - * Looks up the format pattern for the event output by key, conventionally - * equal to the method name. The pattern is used by the - * {#format(String,String,Object...)} method and by default is formatted - * using the {...@link MessageFormat#format()} method. If no pattern is found - * for key or needs to be overridden, the default pattern should be - * returned. - * - * @param key - * the format pattern key - * @param defaultPattern - * the default pattern if no pattern is - * @return The format patter for the given key - */ - protected String lookupPattern(String key, String defaultPattern) { - if (outputPatterns.containsKey(key)) { - return outputPatterns.getProperty(key); - } - return defaultPattern; - } + /** + * Formats event output by key, conventionally equal to the method name. + * + * @param key the event key + * @param defaultPattern the default pattern to return if a custom pattern + * is not found + * @param args the args used to format output + * @return A formatted event output + */ + protected String format(String key, String defaultPattern, Object... args) { + return MessageFormat.format(lookupPattern(key, defaultPattern), args); + } + /** + * Looks up the format pattern for the event output by key, conventionally + * equal to the method name. The pattern is used by the + * {#format(String,String,Object...)} method and by default is formatted + * using the {...@link MessageFormat#format()} method. If no pattern is found + * for key or needs to be overridden, the default pattern should be + * returned. + * + * @param key the format pattern key + * @param defaultPattern the default pattern if no pattern is + * @return The format patter for the given key + */ + protected String lookupPattern(String key, String defaultPattern) { + if (outputPatterns.containsKey(key)) { + return outputPatterns.getProperty(key); + } + return defaultPattern; + } + }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java (1385 => 1386)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -5,6 +5,7 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.definition.ExamplesTable; +import org.jbehave.scenario.definition.StoryDefinition; /** * Allows the runner to report the state of running scenarios @@ -14,6 +15,11 @@ */ public interface ScenarioReporter { + void beforeStory(StoryDefinition story); + + /** + * @deprecated Use beforeStory(StoryDefinition) + */ void beforeStory(Blurb blurb); void afterStory();
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java (1385 => 1386)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java 2009-11-05 22:53:00 UTC (rev 1385) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java 2009-11-25 09:02:20 UTC (rev 1386) @@ -5,6 +5,7 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.definition.ExamplesTable; +import org.jbehave.scenario.definition.StoryDefinition; import org.jbehave.scenario.errors.StepFailure; /** @@ -46,6 +47,11 @@ delegate.beforeStory(blurb); } + public void beforeStory(StoryDefinition story) { + failure = null; + delegate.beforeStory(story); + } + public void failed(String step, Throwable cause) { failure = new StepFailure(step, cause); delegate.failed(step, failure); @@ -75,4 +81,5 @@ delegate.examplesTableRow(tableRow); } + }
To unsubscribe from this list please visit:
