- Revision
- 1574
- Author
- mauro
- Date
- 2010-02-20 10:27:10 -0600 (Sat, 20 Feb 2010)
Log Message
JBEHAVE-230: Updated grammar documentation and html rendering.
Modified Paths
- trunk/core/distribution/src/site/content/grammar.html
- trunk/core/distribution/src/site/content/i18n-scenarios.html
- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/parser/grammar.ebnf
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java
- trunk/core/jbehave-core/src/main/resources/style/jbehave-reports.css
Diff
Modified: trunk/core/distribution/src/site/content/grammar.html (1573 => 1574)
--- trunk/core/distribution/src/site/content/grammar.html 2010-02-20 13:29:11 UTC (rev 1573) +++ trunk/core/distribution/src/site/content/grammar.html 2010-02-20 16:27:10 UTC (rev 1574) @@ -10,9 +10,29 @@ <p>Below is a detailed outlay of the grammar JBehave understands. It is expressed in <a href="" <pre class="brush: bdd"> -; The story or feature is a collection of scenarios -Story := Scenario+ ; +; The story describes a feature via a narrative (optional) and a collection of scenarios +Story := Narrative? Scenario+ ; +; The narrative is identified by keyword "Narrative:" (or equivalent in I18n-ed locale), +; It can optionally be followed by a description, which is expressed by any sequence of words +; that must not contain any keywords. +; It is followed by the narrative elements +Narrative:= "Narrative:" Description? InOrderTo AsA IWantTo ; + +; The narrative elements +InOrderTo:= "In order to" NarrativeElementContent ; +AsA:= "As a" NarrativeElementContent ; +IWantTo:= "I want to" NarrativeElementContent ; + +; The narrative element content is any sequence of characters that do not match a narrative starting word +NarrativeElementContent := ? Any sequence of NarrativeCharacter that does not match NarrativeStartingWord ? ; + +; All characters are allowed in a narrative content, including newlines +NarrativeCharacter := ? Any Unicode character ? ; + +; The narrative starting words (or equivalent in I18n-ed locale) +NarrativeStartingWord :== ("In order to" | "As a" | "I want to" ) ; + ; The scenario is identified by keyword "Scenario:" (or equivalent in I18n-ed locale), ; which is optional in the case of a single scenario. ; It can optionally be followed by a description, which is expressed by any sequence of words @@ -21,7 +41,7 @@ ; Finally the optional Examples table, which if present will execute the scenario for as many table rows present Scenario := "Scenario:"? Description? GivenScenarios? Step+ Examples? ; -; The scenario description +; The free-text description Description := (Word Space?)* ; ; The word is any sequence of non-space characters that does not match a KeyWord
Modified: trunk/core/distribution/src/site/content/i18n-scenarios.html (1573 => 1574)
--- trunk/core/distribution/src/site/content/i18n-scenarios.html 2010-02-20 13:29:11 UTC (rev 1573) +++ trunk/core/distribution/src/site/content/i18n-scenarios.html 2010-02-20 16:27:10 UTC (rev 1574) @@ -25,6 +25,10 @@ for a given Locale. Each locale has a separate keywords properties file. E.g. for Italian locale, the file <b>keywords_it.properties</b> is:</p> <pre class="brush: bdd"> +Narrative=Narrativa: +InOrderTo=Per ottenere +AsA=Come +IWantTo=Voglio Scenario=Scenario: GivenScenarios=Dati gli scenari: ExamplesTable=Esempi:
Modified: trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java (1573 => 1574)
--- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2010-02-20 13:29:11 UTC (rev 1573) +++ trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2010-02-20 16:27:10 UTC (rev 1574) @@ -1,6 +1,7 @@ package org.jbehave.scenario.reporters; import static java.util.Arrays.asList; +import static junit.framework.Assert.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; import static org.jbehave.Ensure.ensureThat; import static org.jbehave.scenario.reporters.ScenarioReporterBuilder.Format.HTML; @@ -90,9 +91,9 @@ 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 class=\"inOrderTo\"><span class=\"keyword inOrderTo\">In order to</span> renovate my house</div>\n" + + "<div class=\"asA\"><span class=\"keyword asA\">As a</span> customer</div>\n" + + "<div class=\"iWantTo\"><span class=\"keyword iWantTo\">I want to</span> 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" @@ -116,7 +117,7 @@ "</div>\n</div>\n"; // end of scenario and story ensureThatOutputIs(out, expected); } - + @Test public void shouldReportEventsToHtmlPrintStreamUsingCustomOutputPatterns() { // Given @@ -140,10 +141,10 @@ 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=\"inOrderTo\"><span class=\"keyword inOrderTo\">In order to</span> renovate my house</div>\n" + + "<div class=\"asA\"><span class=\"keyword asA\">As a</span> customer</div>\n" + + "<div class=\"iWantTo\"><span class=\"keyword iWantTo\">I want to</span> 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" @@ -236,8 +237,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/parser/grammar.ebnf (1573 => 1574)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/parser/grammar.ebnf 2010-02-20 13:29:11 UTC (rev 1573) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/parser/grammar.ebnf 2010-02-20 16:27:10 UTC (rev 1574) @@ -1,8 +1,28 @@ ; JBehave Grammar expressed in EBNF (http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form) -; The story or feature is a collection of scenarios -Story := Scenario+ ; +; The story describes a feature via a narrative (optional) and a collection of scenarios +Story := Narrative? Scenario+ ; +; The narrative is identified by keyword "Narrative:" (or equivalent in I18n-ed locale), +; It can optionally be followed by a description, which is expressed by any sequence of words +; that must not contain any keywords. +; It is followed by the narrative elements +Narrative:= "Narrative:" Description? InOrderTo AsA IWantTo ; + +; The narrative elements +InOrderTo:= "In order to" NarrativeElementContent ; +AsA:= "As a" NarrativeElementContent ; +IWantTo:= "I want to" NarrativeElementContent ; + +; The narrative element content is any sequence of characters that do not match a narrative starting word +NarrativeElementContent := ? Any sequence of NarrativeCharacter that does not match NarrativeStartingWord ? ; + +; All characters are allowed in a narrative content, including newlines +NarrativeCharacter := ? Any Unicode character ? ; + +; The narrative starting words (or equivalent in I18n-ed locale) +NarrativeStartingWord :== ("In order to" | "As a" | "I want to" ) ; + ; The scenario is identified by keyword "Scenario:" (or equivalent in I18n-ed locale), ; which is optional in the case of a single scenario. ; It can optionally be followed by a description, which is expressed by any sequence of words @@ -11,7 +31,7 @@ ; Finally the optional Examples table, which if present will execute the scenario for as many table rows present Scenario := "Scenario:"? Description? GivenScenarios? Step+ Examples? ; -; The scenario description +; The free-text description Description := (Word Space?)* ; ; The word is any sequence of non-space characters that does not match a KeyWord
Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java (1573 => 1574)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java 2010-02-20 13:29:11 UTC (rev 1573) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/reporters/HtmlPrintStreamScenarioReporter.java 2010-02-20 16:27:10 UTC (rev 1574) @@ -47,7 +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("narrative", "<div class=\"narrative\">{0}\n<div class=\"inOrderTo\"><span class=\"keyword inOrderTo\">{1}</span> {2}</div>\n<div class=\"asA\"><span class=\"keyword asA\">{3}</span> {4}</div>\n<div class=\"iWantTo\"><span class=\"keyword iWantTo\">{5}</span> {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/resources/style/jbehave-reports.css (1573 => 1574)
--- trunk/core/jbehave-core/src/main/resources/style/jbehave-reports.css 2010-02-20 13:29:11 UTC (rev 1573) +++ trunk/core/jbehave-core/src/main/resources/style/jbehave-reports.css 2010-02-20 16:27:10 UTC (rev 1574) @@ -126,6 +126,10 @@ color: purple; } +span.inOrderTo, span.asA, span.iWantTo { + font-weight: bold; +} + .path, .givenScenarios { font-weight: bold; font-size: 16px;
To unsubscribe from this list please visit:
