- Revision
- 1236
- Author
- mauro
- Date
- 2009-09-10 03:04:36 -0500 (Thu, 10 Sep 2009)
Log Message
Added I18n support to PrintStreamScenarioReporter. Added keywords for pending, not performed, failed.
Modified Paths
- 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/definition/KeyWords.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_en.properties
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_es.properties
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_it.properties
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_pt.properties
- 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
Diff
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java (1235 => 1236)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2009-09-10 08:04:36 UTC (rev 1236) @@ -6,6 +6,7 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import org.jbehave.scenario.i18n.I18nKeyWords; import org.junit.Test; @@ -38,7 +39,7 @@ exception.printStackTrace(new PrintStream(stackTrace)); ByteArrayOutputStream out = new ByteArrayOutputStream(); - ScenarioReporter reporter = new PrintStreamScenarioReporter(new PrintStream(out), true); + ScenarioReporter reporter = new PrintStreamScenarioReporter(new PrintStream(out), new I18nKeyWords(), true); reporter.beforeScenario("A title"); reporter.successful("Given I have a balance of $50"); reporter.successful("When I request $20"); @@ -57,7 +58,7 @@ stackTrace + NL)); out = new ByteArrayOutputStream(); - reporter = new PrintStreamScenarioReporter(new PrintStream(out), false); + reporter = new PrintStreamScenarioReporter(new PrintStream(out)); reporter.beforeScenario("A title"); reporter.successful("Given I have a balance of $50"); reporter.successful("When I request $20");
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java 2009-09-10 08:04:36 UTC (rev 1236) @@ -70,9 +70,9 @@ private void runTemplateScenario(Configuration configuration, ScenarioDefinition scenario, ExamplesTable table, CandidateSteps... candidateSteps) { - reporter.usingExamplesTable(table); + reporter.examplesTable(table); for (Map<String,String> tableRow : table.getRows() ) { - reporter.usingTableRow(tableRow); + reporter.examplesTableRow(tableRow); runScenario(configuration, scenario, tableRow, candidateSteps); } }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/KeyWords.java (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/KeyWords.java 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/KeyWords.java 2009-09-10 08:04:36 UTC (rev 1236) @@ -1,6 +1,7 @@ package org.jbehave.scenario.definition; -import java.util.Arrays; +import static java.util.Arrays.asList; + import java.util.List; import java.util.Map; @@ -13,13 +14,19 @@ static final String SCENARIO = "Scenario"; static final String GIVEN_SCENARIOS = "GivenScenarios"; + static final String EXAMPLES_TABLE = "ExamplesTable"; static final String GIVEN = "Given"; static final String WHEN = "When"; static final String THEN = "Then"; static final String AND = "And"; - static final String EXAMPLES_TABLE = "ExamplesTable"; - protected static final List<String> KEYWORDS = Arrays.asList(SCENARIO, GIVEN_SCENARIOS, GIVEN, WHEN, THEN, AND, EXAMPLES_TABLE); - + static final String PENDING = "Pending"; + static final String NOT_PERFORMED = "NotPerformed"; + static final String FAILED = "Failed"; + static final String EXAMPLES_TABLE_ROW = "ExamplesTableRow"; + protected static final List<String> KEYWORDS = asList(SCENARIO, + GIVEN_SCENARIOS, EXAMPLES_TABLE, GIVEN, WHEN, THEN, AND, PENDING, + NOT_PERFORMED, FAILED, EXAMPLES_TABLE_ROW); + private final String scenario; private final String givenScenarios; private final String given; @@ -30,11 +37,14 @@ public KeyWords(Map<String, String> keywords) { this(keywords.get(SCENARIO), keywords.get(GIVEN_SCENARIOS), keywords - .get(EXAMPLES_TABLE), keywords.get(GIVEN), keywords.get(WHEN), keywords.get(THEN), keywords.get(AND)); + .get(EXAMPLES_TABLE), keywords.get(GIVEN), keywords.get(WHEN), + keywords.get(THEN), keywords.get(AND), keywords.get(PENDING), + keywords.get(NOT_PERFORMED), keywords.get(FAILED), keywords.get(EXAMPLES_TABLE_ROW)); } - public KeyWords(String scenario, String givenScenarios, String examplesTable, - String given, String when, String then, String... others) { + public KeyWords(String scenario, String givenScenarios, + String examplesTable, String given, String when, String then, + String... others) { this.scenario = scenario; this.givenScenarios = givenScenarios; this.examplesTable = examplesTable; @@ -72,6 +82,22 @@ return others[0]; } + public String pending() { + return others[1]; + } + + public String notPerformed() { + return others[2]; + } + + public String failed() { + return others[3]; + } + + public String examplesTableRow() { + return others[4]; + } + public String[] others() { return others; }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_en.properties (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_en.properties 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_en.properties 2009-09-10 08:04:36 UTC (rev 1236) @@ -1,7 +1,11 @@ Scenario=Scenario: GivenScenarios=GivenScenarios: ExamplesTable=Examples: +ExamplesTableRow=Example: Given=Given When=When Then=Then And=And +Pending=PENDING +NotPerformed=NOT PERFORMED +Failed=FAILED
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_es.properties (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_es.properties 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_es.properties 2009-09-10 08:04:36 UTC (rev 1236) @@ -1,7 +1,11 @@ Scenario=Escenario: GivenScenarios=Dados los escenarios: ExamplesTable=Ejemplos: +ExamplesTableRow=Ejemplo: Given=Dado que When=Cuando Then=Entonces And=Y +Pending=PENDING +NotPerformed=NOT PERFORMED +Failed=FAILED
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_it.properties (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_it.properties 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_it.properties 2009-09-10 08:04:36 UTC (rev 1236) @@ -1,7 +1,11 @@ Scenario=Scenario: GivenScenarios=Dati gli scenari: ExamplesTable=Esempi: +ExamplesTableRow=Esempio: Given=Dato che When=Quando Then=Allora And=E +Pending=PENDENTE +NotPerformed=NON ESEGUITO +Failed=FALLITO
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_pt.properties (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_pt.properties 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_pt.properties 2009-09-10 08:04:36 UTC (rev 1236) @@ -1,7 +1,11 @@ Scenario=Cen\u00E1rio: GivenScenarios=Dados os cen\u00E1rios: ExamplesTable=Exemplos: +ExamplesTableRow=Exemplo: Given=Dado que When=Quando Then=Ent\u00E3o -And=E \ No newline at end of file +And=E +Pending=PENDING +NotPerformed=NON PERFORMED +Failed=FAILED
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java 2009-09-10 08:04:36 UTC (rev 1236) @@ -114,18 +114,18 @@ }); } - public void usingExamplesTable(final ExamplesTable table) { + public void examplesTable(final ExamplesTable table) { currentScenario.add(new Todo() { public void doNow() { - delegate.usingExamplesTable(table); + delegate.examplesTable(table); } }); } - public void usingTableRow(final Map<String, String> tableRow) { + public void examplesTableRow(final Map<String, String> tableRow) { currentScenario.add(new Todo() { public void doNow() { - delegate.usingTableRow(tableRow); + delegate.examplesTableRow(tableRow); } }); }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2009-09-10 08:04:36 UTC (rev 1236) @@ -7,6 +7,8 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.definition.ExamplesTable; +import org.jbehave.scenario.definition.KeyWords; +import org.jbehave.scenario.i18n.I18nKeyWords; /** * <p> @@ -16,6 +18,7 @@ public class PrintStreamScenarioReporter implements ScenarioReporter { private final PrintStream output; + private final KeyWords keywords; private final boolean reportErrors; private Throwable cause; @@ -24,11 +27,12 @@ } public PrintStreamScenarioReporter(PrintStream output) { - this(output, false); + this(output, new I18nKeyWords(), false); } - public PrintStreamScenarioReporter(PrintStream output, boolean reportErrors) { + public PrintStreamScenarioReporter(PrintStream output, KeyWords keywords, boolean reportErrors) { this.output = output; + this.keywords = keywords; this.reportErrors = reportErrors; } @@ -37,16 +41,16 @@ } public void pending(String step) { - output.println(format("pending", "{0} (PENDING)", step)); + output.println(format("pending", "{0} ({1})", step, keywords.pending())); } public void notPerformed(String step) { - output.println(format("notPerformed", "{0} (NOT PERFORMED)", step)); + output.println(format("notPerformed", "{0} ({1})", step, keywords.notPerformed())); } public void failed(String step, Throwable cause) { this.cause = cause; - output.println(format("failed", "{0} (FAILED)", step)); + output.println(format("failed", "{0} ({1})", step, keywords.failed())); } public void afterScenario() { @@ -59,7 +63,7 @@ public void beforeScenario(String title) { cause = null; - output.println(format("beforeScenario", "Scenario: {0}\n", title)); + output.println(format("beforeScenario", "{0} {1}\n", keywords.scenario(), title)); } public void afterStory() { @@ -71,17 +75,17 @@ } public void givenScenarios(List<String> givenScenarios) { - output.println(format("givenScenarios", "GivenScenarios: {0}\n", - givenScenarios)); + output.println(format("givenScenarios", "{0} {1}\n", + keywords.givenScenarios(), givenScenarios)); } - public void usingExamplesTable(ExamplesTable table) { - output.println(format("usingExamplesTable", - "Using examples table:\n\n{0}\n\n", table)); + public void examplesTable(ExamplesTable table) { + output.println(format("examplesTable", + "{0}\n\n{1}\n\n", keywords.examplesTable(), table)); } - public void usingTableRow(Map<String, String> tableRow) { - output.println(format("usingTableRow", "Using table row: {0}\n", tableRow)); + public void examplesTableRow(Map<String, String> tableRow) { + output.println(format("tableRow", "{0} {1}\n", keywords.examplesTableRow(), tableRow)); } protected String format(String key, String defaultPattern, Object... args) {
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java 2009-09-10 08:04:36 UTC (rev 1236) @@ -24,9 +24,9 @@ void givenScenarios(List<String> givenScenarios); - void usingExamplesTable(ExamplesTable table); + void examplesTable(ExamplesTable table); - void usingTableRow(Map<String, String> tableRow); + void examplesTableRow(Map<String, String> tableRow); void successful(String step);
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java (1235 => 1236)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java 2009-09-08 12:53:12 UTC (rev 1235) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java 2009-09-10 08:04:36 UTC (rev 1236) @@ -67,12 +67,12 @@ delegate.givenScenarios(givenScenarios); } - public void usingExamplesTable(ExamplesTable table) { - delegate.usingExamplesTable(table); + public void examplesTable(ExamplesTable table) { + delegate.examplesTable(table); } - public void usingTableRow(Map<String, String> tableRow) { - delegate.usingTableRow(tableRow); + public void examplesTableRow(Map<String, String> tableRow) { + delegate.examplesTableRow(tableRow); } }
To unsubscribe from this list please visit:
