- Revision
- 1573
- Author
- mauro
- Date
- 2010-02-20 07:29:11 -0600 (Sat, 20 Feb 2010)
Log Message
JBEHAVE-230: Updated reports to be narrative-aware.
Modified Paths
- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario
- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/definition/Narrative.java
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/XmlPrintStreamScenarioReporter.java
- trunk/core/jbehave-core/src/main/resources/js/shBrushTxt.js
- trunk/core/jbehave-core/src/main/resources/style/jbehave-reports.css
Diff
Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario (1572 => 1573)
--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario 2010-02-20 12:15:52 UTC (rev 1572) +++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario 2010-02-20 13:29:11 UTC (rev 1573) @@ -1,10 +1,12 @@ Trader is alerted of status -Scenario: +Narrative: In order to ensure a quick response As a trader I want to monitor stock prices +Scenario: + Given a stock of symbol STK1 and a threshold of 15.0 When the stock is traded at price 5.0 Then the alert status is OFF @@ -14,9 +16,6 @@ Then the alert status is ON Scenario: -In order to ensure a quick response -As a trader -I want to monitor stock prices Given a stock of <symbol> and a <threshold> When the stock is traded with <price>
Modified: trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java (1572 => 1573)
--- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2010-02-20 12:15:52 UTC (rev 1572) +++ trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2010-02-20 13:29:11 UTC (rev 1573) @@ -5,7 +5,6 @@ import static org.jbehave.Ensure.ensureThat; import static org.jbehave.scenario.reporters.ScenarioReporterBuilder.Format.HTML; import static org.jbehave.scenario.reporters.ScenarioReporterBuilder.Format.TXT; -import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; import java.io.File; @@ -46,6 +45,10 @@ // Then String expected = "An interesting story\n" + "(/path/to/story)\n" + + "Narrative:\n" + + "In order to renovate my house\n" + + "As a customer\n" + + "I want to get a loan\n" + "Scenario: I ask for a loan\n" + "GivenScenarios: [/given/scenario1,/given/scenario2]\n" + "Given I have a balance of $50\n" @@ -82,10 +85,15 @@ // When narrateAnInterestingStory(reporter); - + // Then String expected = "<div class=\"story\">\n<h1>An interesting story</h1>\n" + "<div class=\"path\">/path/to/story</div>\n" + + "<div class=\"narrative\">Narrative:\n" + + "<div class=\"narrative inOrderTo\">In order to renovate my house</div>\n" + + "<div class=\"narrative asA\">As a customer</div>\n" + + "<div class=\"narrative iWantTo\">I want to get a loan</div>\n" + + "</div>\n" + "<div class=\"scenario\">\n<h2>Scenario: I ask for a loan</h2>\n" + "<div class=\"givenScenarios\">GivenScenarios: [/given/scenario1,/given/scenario2]</div>\n" + "<div class=\"step successful\">Given I have a balance of $50</div>\n" @@ -131,6 +139,11 @@ // Then String expected = "<div class=\"story\">\n<h1>An interesting story</h1>\n" + "<div class=\"path\">/path/to/story</div>\n" + + "<div class=\"narrative\">Narrative:\n" + + "<div class=\"narrative inOrderTo\">In order to renovate my house</div>\n" + + "<div class=\"narrative asA\">As a customer</div>\n" + + "<div class=\"narrative iWantTo\">I want to get a loan</div>\n" + + "</div>\n" + "<div class=\"scenario\">\n<h2>Scenario: I ask for a loan</h2>\n" + "<div class=\"givenScenarios\">GivenScenarios: [/given/scenario1,/given/scenario2]</div>\n" + "<div class=\"step successful\">Given I have a balance of $50</div>\n" @@ -167,8 +180,14 @@ // When narrateAnInterestingStory(reporter); + // Then String expected = "<story path=\"/path/to/story\" title=\"An interesting story\">\n" + + "<narrative keyword=\"Narrative:\">\n" + + " <inOrderTo keyword=\"In order to\">renovate my house</inOrderTo>\n" + + " <asA keyword=\"As a\">customer</asA>\n" + + " <iWantTo keyword=\"I want to\">get a loan</iWantTo>\n" + + "</narrative>\n" + "<scenario keyword=\"Scenario:\" title=\"I ask for a loan\">\n" + "<givenScenarios keyword=\"GivenScenarios:\"paths=\"[/given/scenario1,/given/scenario2]\"</givenScenarios>\n" + "<step outcome=\"successful\">Given I have a balance of $50</step>\n" @@ -217,8 +236,8 @@ private void ensureThatOutputIs(OutputStream out, String expected) { // JUnit assertion allows easier comparison of strings in IDE - assertEquals(expected, dos2unix(out.toString())); - // ensureThat(out.toString(), equalTo(expected)); + //assertEquals(expected, dos2unix(out.toString())); + ensureThat(out.toString(), equalTo(expected)); } private String dos2unix(String string) {
Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/definition/Narrative.java (1572 => 1573)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/definition/Narrative.java 2010-02-20 12:15:52 UTC (rev 1572) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/definition/Narrative.java 2010-02-20 13:29:11 UTC (rev 1573) @@ -29,9 +29,14 @@ return iWantTo; } + public boolean isEmpty() { + return EMPTY == this; + } + @Override public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); } + }
Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java (1572 => 1573)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java 2010-02-20 12:15:52 UTC (rev 1572) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java 2010-02-20 13:29:11 UTC (rev 1573) @@ -47,6 +47,7 @@ patterns.setProperty("notPerformed", "<div class=\"step notPerformed\">{0} <span class=\"keyword notPerformed\">({1})</span></div>\n"); patterns.setProperty("failed", "<div class=\"step failed\">{0} <span class=\"keyword failed\">({1})</span></div>\n"); patterns.setProperty("beforeStory", "<div class=\"story\">\n<h1>{0}</h1>\n<div class=\"path\">{1}</div>\n"); + patterns.setProperty("narrative", "<div class=\"narrative\">{0}\n<div class=\"narrative inOrderTo\">{1} {2}</div>\n<div class=\"narrative asA\">{3} {4}</div>\n<div class=\"narrative iWantTo\">{5} {6}</div>\n</div>\n"); patterns.setProperty("afterStory", "</div>\n"); patterns.setProperty("beforeScenario", "<div class=\"scenario\">\n<h2>{0} {1}</h2>\n"); patterns.setProperty("afterScenario", "</div>\n");
Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java (1572 => 1573)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2010-02-20 12:15:52 UTC (rev 1572) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2010-02-20 13:29:11 UTC (rev 1573) @@ -22,6 +22,7 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.definition.ExamplesTable; import org.jbehave.scenario.definition.KeyWords; +import org.jbehave.scenario.definition.Narrative; import org.jbehave.scenario.definition.StoryDefinition; import org.jbehave.scenario.i18n.I18nKeyWords; @@ -133,7 +134,12 @@ } public void beforeStory(StoryDefinition story, boolean embeddedStory) { - print(format("beforeStory", "{0}\n({1})\n", story.getBlurb().asString(), story.getPath())); + print(format("beforeStory", "{0}\n({1})\n", story.getBlurb().asString(), story.getPath())); + if (!story.getNarrative().isEmpty()) { + Narrative narrative = story.getNarrative(); + print(format("narrative", "{0}\n{1} {2}\n{3} {4}\n{5} {6}\n", keywords.narrative(), keywords.inOrderTo(), + narrative.inOrderTo(), keywords.asA(), narrative.asA(), keywords.iWantTo(), narrative.iWantTo())); + } } public void beforeStory(Blurb blurb) {
Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/XmlPrintStreamScenarioReporter.java (1572 => 1573)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/XmlPrintStreamScenarioReporter.java 2010-02-20 12:15:52 UTC (rev 1572) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/XmlPrintStreamScenarioReporter.java 2010-02-20 13:29:11 UTC (rev 1573) @@ -46,6 +46,7 @@ patterns.setProperty("notPerformed", "<step outcome=\"notPerformed\" keyword=\"{1}\">{0}</step>\n"); patterns.setProperty("failed", "<step outcome=\"failed\" keyword=\"{1}\">{0}</step>\n"); patterns.setProperty("beforeStory", "<story path=\"{1}\" title=\"{0}\">\n"); + patterns.setProperty("narrative", "<narrative keyword=\"{0}\">\n <inOrderTo keyword=\"{1}\">{2}</inOrderTo>\n <asA keyword=\"{3}\">{4}</asA>\n <iWantTo keyword=\"{5}\">{6}</iWantTo>\n</narrative>\n"); patterns.setProperty("afterStory", "</story>\n"); patterns.setProperty("beforeScenario", "<scenario keyword=\"{0}\" title=\"{1}\">\n"); patterns.setProperty("afterScenario", "</scenario>\n");
Modified: trunk/core/jbehave-core/src/main/resources/js/shBrushTxt.js (1572 => 1573)
--- trunk/core/jbehave-core/src/main/resources/js/shBrushTxt.js 2010-02-20 12:15:52 UTC (rev 1572) +++ trunk/core/jbehave-core/src/main/resources/js/shBrushTxt.js 2010-02-20 13:29:11 UTC (rev 1573) @@ -5,7 +5,7 @@ */ SyntaxHighlighter.brushes.Txt = function() { - var keywords = 'Given When Then And Scenario GivenScenarios Examples Example PENDING NOT PERFORMED FAILED'; + var keywords = 'Narrative Given When Then And Scenario GivenScenarios Examples Example PENDING NOT PERFORMED FAILED'; this.regexList = [ { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // txt keyword
Modified: trunk/core/jbehave-core/src/main/resources/style/jbehave-reports.css (1572 => 1573)
--- trunk/core/jbehave-core/src/main/resources/style/jbehave-reports.css 2010-02-20 12:15:52 UTC (rev 1572) +++ trunk/core/jbehave-core/src/main/resources/style/jbehave-reports.css 2010-02-20 13:29:11 UTC (rev 1573) @@ -120,6 +120,12 @@ border-color: #ffcd13; } +.narrative { + text-align: left; + margin-left: 10px; + color: purple; +} + .path, .givenScenarios { font-weight: bold; font-size: 16px;
To unsubscribe from this list please visit:
