- Revision
- 1224
- Author
- mauro
- Date
- 2009-09-05 10:58:21 -0500 (Sat, 05 Sep 2009)
Log Message
Report both entire scenario table and single table rows. Renamed tableValues params to tableRow for better expressivity.
Modified Paths
- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java
- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java
- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepsBehaviour.java
- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.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
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/StepCreator.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreator.java
Diff
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java (1223 => 1224)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -33,7 +33,7 @@ public class ScenarioRunnerBehaviour { - private Map<String, String> tableValues = new HashMap<String, String>(); + private Map<String, String> tableRow = new HashMap<String, String>(); @Test public void shouldRunStepsInScenariosAndReportResultsToReporter() throws Throwable { @@ -63,9 +63,9 @@ stub(successfulStep.doNotPerform()).toReturn(StepResult.notPerformed("successfulStep")); stub(failingStep.perform()).toReturn(StepResult.failure("failingStep", anException)); - stub(creator.createStepsFrom(scenarioDefinition1, tableValues, mySteps)).toReturn(new Step[] {failingStep, successfulStep}); - stub(creator.createStepsFrom(scenarioDefinition2, tableValues, mySteps)).toReturn(new Step[] {successfulStep}); - stub(creator.createStepsFrom(scenarioDefinition3, tableValues, mySteps)).toReturn(new Step[] {successfulStep, pendingStep}); + stub(creator.createStepsFrom(scenarioDefinition1, tableRow, mySteps)).toReturn(new Step[] {failingStep, successfulStep}); + stub(creator.createStepsFrom(scenarioDefinition2, tableRow, mySteps)).toReturn(new Step[] {successfulStep}); + stub(creator.createStepsFrom(scenarioDefinition3, tableRow, mySteps)).toReturn(new Step[] {successfulStep, pendingStep}); ErrorStrategy errorStrategy = mock(ErrorStrategy.class); ScenarioRunner runner = new ScenarioRunner(); @@ -114,8 +114,8 @@ Step anotherSuccessfulStep = mock(Step.class); stub(anotherSuccessfulStep.perform()).toReturn(StepResult.success("anotherSuccessfulStep")); - stub(creator.createStepsFrom(scenarioDefinition1, tableValues, mySteps)).toReturn(new Step[] {successfulStep}); - stub(creator.createStepsFrom(scenarioDefinition2, tableValues, mySteps)).toReturn(new Step[] {anotherSuccessfulStep}); + stub(creator.createStepsFrom(scenarioDefinition1, tableRow, mySteps)).toReturn(new Step[] {successfulStep}); + stub(creator.createStepsFrom(scenarioDefinition2, tableRow, mySteps)).toReturn(new Step[] {anotherSuccessfulStep}); stub(scenarioDefiner.loadScenarioDefinitionsFor("/path/to/given/scenario1")).toReturn(storyDefinition1); @@ -145,7 +145,7 @@ StepCreator creator = mock(StepCreator.class); Steps mySteps = mock(Steps.class); - stub(creator.createStepsFrom((ScenarioDefinition)anyObject(), eq(tableValues), eq(mySteps))) + stub(creator.createStepsFrom((ScenarioDefinition)anyObject(), eq(tableRow), eq(mySteps))) .toReturn(new Step[] {firstStepNormal, secondStepPending, thirdStepNormal, fourthStepAlsoPending}); ScenarioRunner runner = new ScenarioRunner(); @@ -186,7 +186,7 @@ Steps mySteps = mock(Steps.class); ErrorStrategy errorStrategy = mock(ErrorStrategy.class); - stub(creator.createStepsFrom((ScenarioDefinition)anyObject(), eq(tableValues), eq(mySteps))) + stub(creator.createStepsFrom((ScenarioDefinition)anyObject(), eq(tableRow), eq(mySteps))) .toReturn(new Step[] {firstStepExceptional, secondStepNotPerformed}); ScenarioRunner runner = new ScenarioRunner(); @@ -223,9 +223,9 @@ ScenarioDefinition scenario1 = mock(ScenarioDefinition.class); ScenarioDefinition scenario2 = mock(ScenarioDefinition.class); - stub(creator.createStepsFrom(scenario1, tableValues, mySteps)) + stub(creator.createStepsFrom(scenario1, tableRow, mySteps)) .toReturn(new Step[] {pendingStep}); - stub(creator.createStepsFrom(scenario2, tableValues, mySteps)) + stub(creator.createStepsFrom(scenario2, tableRow, mySteps)) .toReturn(new Step[] {secondStep}); ScenarioRunner runner = new ScenarioRunner(); @@ -250,7 +250,7 @@ StepCreator creator = mock(StepCreator.class); Steps mySteps = mock(Steps.class); - stub(creator.createStepsFrom((ScenarioDefinition)anyObject(), eq(tableValues), eq(mySteps))) + stub(creator.createStepsFrom((ScenarioDefinition)anyObject(), eq(tableRow), eq(mySteps))) .toReturn(new Step[] {pendingStep}); new ScenarioRunner().run(new StoryDefinition(new ScenarioDefinition("")), configurationWithPendingStrategy(creator, reporter, strategy), mySteps);
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java (1223 => 1224)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -31,7 +31,7 @@ private static final StepPatternBuilder PATTERN_BUILDER = new PrefixCapturingPatternBuilder(); private static final StepMonitor MONITOR = new SilentStepMonitor(); private static final String NL = System.getProperty("line.separator"); - private Map<String, String> tableValues = new HashMap<String, String>(); + private Map<String, String> tableRow = new HashMap<String, String>(); private Paranamer paranamer = new CachingParanamer(new BytecodeReadingParanamer()); @Test @@ -54,7 +54,7 @@ SomeSteps someSteps = new SomeSteps(); CandidateStep candidateStep = new CandidateStep("I live on the $nth floor", SomeSteps.class.getMethod( "aMethodWith", String.class), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - Step step = candidateStep.createFrom(tableValues, "Then I live on the 1st floor"); + Step step = candidateStep.createFrom(tableRow, "Then I live on the 1st floor"); step.perform(); ensureThat((String) someSteps.args, equalTo("1st")); } @@ -71,22 +71,22 @@ SomeSteps someSteps = new SomeSteps(); CandidateStep candidateStep = new CandidateStep("I should live in no. $no", SomeSteps.class.getMethod( "aMethodWith", int.class), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "Then I should live in no. 14").perform(); + candidateStep.createFrom(tableRow, "Then I should live in no. 14").perform(); ensureThat((Integer) someSteps.args, equalTo(14)); candidateStep = new CandidateStep("I should live in no. $no", SomeSteps.class.getMethod("aMethodWith", long.class), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "Then I should live in no. 14").perform(); + candidateStep.createFrom(tableRow, "Then I should live in no. 14").perform(); ensureThat((Long) someSteps.args, equalTo(14L)); candidateStep = new CandidateStep("I should live in no. $no", SomeSteps.class.getMethod("aMethodWith", double.class), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "Then I should live in no. 14").perform(); + candidateStep.createFrom(tableRow, "Then I should live in no. 14").perform(); ensureThat((Double) someSteps.args, equalTo(14.0)); candidateStep = new CandidateStep("I should live in no. $no", SomeSteps.class.getMethod("aMethodWith", float.class), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "Then I should live in no. 14").perform(); + candidateStep.createFrom(tableRow, "Then I should live in no. 14").perform(); ensureThat((Float) someSteps.args, equalTo(14.0f)); } @@ -96,7 +96,7 @@ SomeSteps someSteps = new SomeSteps(); CandidateStep candidateStep = new CandidateStep("I live on the $nth floor", SomeSteps.class.getMethod( "aMethodWith", String.class), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - Step step = candidateStep.createFrom(tableValues, "Then I live on the 1st floor"); + Step step = candidateStep.createFrom(tableRow, "Then I live on the 1st floor"); StepResult result = step.perform(); result.describeTo(reporter); @@ -111,7 +111,7 @@ SomeSteps someSteps = new SomeSteps(); CandidateStep candidateStep = new CandidateStep("the grid should look like $grid", SomeSteps.class.getMethod( "aMethodWith", String.class), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - Step step = candidateStep.createFrom(tableValues, "Then the grid should look like" + windowsNewline + ".." + unixNewline + Step step = candidateStep.createFrom(tableRow, "Then the grid should look like" + windowsNewline + ".." + unixNewline + ".." + windowsNewline); step.perform(); ensureThat((String) someSteps.args, equalTo(".." + systemNewline + ".." + systemNewline)); @@ -122,22 +122,22 @@ SomeSteps someSteps = new SomeSteps(); CandidateStep candidateStep = new CandidateStep("windows on the $nth floors", SomeSteps.methodFor("aMethodWithListOfLongs"), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "When windows on the 1L,2L,3L floors").perform(); + candidateStep.createFrom(tableRow, "When windows on the 1L,2L,3L floors").perform(); ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList(1L, 2L, 3L).toString())); candidateStep = new CandidateStep("windows on the $nth floors", SomeSteps.methodFor("aMethodWithListOfIntegers"), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "When windows on the 1,2,3 floors").perform(); + candidateStep.createFrom(tableRow, "When windows on the 1,2,3 floors").perform(); ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList(1, 2, 3).toString())); candidateStep = new CandidateStep("windows on the $nth floors", SomeSteps.methodFor("aMethodWithListOfDoubles"), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "When windows on the 1.1,2.2,3.3 floors").perform(); + candidateStep.createFrom(tableRow, "When windows on the 1.1,2.2,3.3 floors").perform(); ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList(1.1, 2.2, 3.3).toString())); candidateStep = new CandidateStep("windows on the $nth floors", SomeSteps.methodFor("aMethodWithListOfFloats"), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "When windows on the 1.1f,2.2f,3.3f floors").perform(); + candidateStep.createFrom(tableRow, "When windows on the 1.1f,2.2f,3.3f floors").perform(); ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList(1.1f, 2.2f, 3.3f).toString())); } @@ -147,7 +147,7 @@ SomeSteps someSteps = new SomeSteps(); CandidateStep candidateStep = new CandidateStep("windows on the $nth floors", SomeSteps.methodFor("aMethodWithListOfStrings"), someSteps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "When windows on the 1,2,3 floors").perform(); + candidateStep.createFrom(tableRow, "When windows on the 1,2,3 floors").perform(); ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList("1", "2", "3").toString())); } @@ -156,7 +156,7 @@ NamedParameterStepsViaNamedAnnotation steps = new NamedParameterStepsViaNamedAnnotation(); CandidateStep candidateStep = new CandidateStep("I live on the $ith floor but some call it the $nth", NamedParameterStepsViaNamedAnnotation.methodFor("methodWithNamedParametersInNaturalOrder"), steps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "When I live on the first floor but some call it the ground").perform(); + candidateStep.createFrom(tableRow, "When I live on the first floor but some call it the ground").perform(); ensureThat(steps.ith, equalTo("first")); ensureThat(steps.nth, equalTo("ground")); } @@ -166,7 +166,7 @@ NamedParameterStepsViaNamedAnnotation steps = new NamedParameterStepsViaNamedAnnotation(); CandidateStep candidateStep = new CandidateStep("I live on the $ith floor but some call it the $nth", NamedParameterStepsViaNamedAnnotation.methodFor("methodWithNamedParametersInInverseOrder"), steps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "When I live on the first floor but some call it the ground").perform(); + candidateStep.createFrom(tableRow, "When I live on the first floor but some call it the ground").perform(); ensureThat(steps.ith, equalTo("first")); ensureThat(steps.nth, equalTo("ground")); } @@ -174,11 +174,11 @@ @Test public void shouldCreateStepFromTableValuesViaAnnotations() throws Exception { NamedParameterStepsViaNamedAnnotation steps = new NamedParameterStepsViaNamedAnnotation(); - tableValues.put("ith", "first"); - tableValues.put("nth", "ground"); + tableRow.put("ith", "first"); + tableRow.put("nth", "ground"); CandidateStep candidateStep = new CandidateStep("I live on the ith floor but some call it the nth", NamedParameterStepsViaNamedAnnotation.methodFor("methodWithNamedParametersInNaturalOrder"), steps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); - candidateStep.createFrom(tableValues, "When I live on the <ith> floor but some call it the <nth>").perform(); + candidateStep.createFrom(tableRow, "When I live on the <ith> floor but some call it the <nth>").perform(); ensureThat(steps.ith, equalTo("first")); ensureThat(steps.nth, equalTo("ground")); } @@ -215,7 +215,7 @@ CandidateStep candidateStep = new CandidateStep("I live on the $ith floor but some call it the $nth", NamedParameterStepsViaParanamer.methodFor("methodWithNamedParametersInNaturalOrder"), steps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); candidateStep.useParanamer(paranamer); - candidateStep.createFrom(tableValues, "When I live on the first floor but some call it the ground").perform(); + candidateStep.createFrom(tableRow, "When I live on the first floor but some call it the ground").perform(); ensureThat(steps.ith, equalTo("first")); ensureThat(steps.nth, equalTo("ground")); } @@ -226,7 +226,7 @@ CandidateStep candidateStep = new CandidateStep("I live on the $ith floor but some call it the $nth", NamedParameterStepsViaParanamer.methodFor("methodWithNamedParametersInInverseOrder"), steps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); candidateStep.useParanamer(paranamer); - candidateStep.createFrom(tableValues, "When I live on the first floor but some call it the ground").perform(); + candidateStep.createFrom(tableRow, "When I live on the first floor but some call it the ground").perform(); ensureThat(steps.ith, equalTo("first")); ensureThat(steps.nth, equalTo("ground")); } @@ -234,12 +234,12 @@ @Test public void shouldCreateStepFromTableValuesViaParanamer() throws Exception { NamedParameterStepsViaParanamer steps = new NamedParameterStepsViaParanamer(); - tableValues.put("ith", "first"); - tableValues.put("nth", "ground"); + tableRow.put("ith", "first"); + tableRow.put("nth", "ground"); CandidateStep candidateStep = new CandidateStep("I live on the ith floor but some call it the nth", NamedParameterStepsViaParanamer.methodFor("methodWithNamedParametersInNaturalOrder"), steps, PATTERN_BUILDER, MONITOR, new ParameterConverters(), "Given", "When", "Then"); candidateStep.useParanamer(paranamer); - candidateStep.createFrom(tableValues, "When I live on the <ith> floor but some call it the <nth>").perform(); + candidateStep.createFrom(tableRow, "When I live on the <ith> floor but some call it the <nth>").perform(); ensureThat(steps.ith, equalTo("first")); ensureThat(steps.nth, equalTo("ground")); }
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepsBehaviour.java (1223 => 1224)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepsBehaviour.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepsBehaviour.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -13,7 +13,7 @@ public class StepsBehaviour { - private Map<String, String> tableValues = new HashMap<String, String>(); + private Map<String, String> tableRow = new HashMap<String, String>(); @Test public void shouldProvideCandidateStepsCorrespondingToAnnotatedStepsWithMultipleAliases() { @@ -21,15 +21,15 @@ CandidateStep[] candidateSteps = steps.getSteps(); ensureThat(candidateSteps.length, equalTo(9)); - candidateSteps[0].createFrom(tableValues, "Given a given").perform(); - candidateSteps[1].createFrom(tableValues, "Given a given alias").perform(); - candidateSteps[2].createFrom(tableValues, "Given another given alias").perform(); - candidateSteps[3].createFrom(tableValues, "When a when").perform(); - candidateSteps[4].createFrom(tableValues, "When a when alias").perform(); - candidateSteps[5].createFrom(tableValues, "When another when alias").perform(); - candidateSteps[6].createFrom(tableValues, "Then a then").perform(); - candidateSteps[7].createFrom(tableValues, "Then a then alias").perform(); - candidateSteps[8].createFrom(tableValues, "Then another then alias").perform(); + candidateSteps[0].createFrom(tableRow, "Given a given").perform(); + candidateSteps[1].createFrom(tableRow, "Given a given alias").perform(); + candidateSteps[2].createFrom(tableRow, "Given another given alias").perform(); + candidateSteps[3].createFrom(tableRow, "When a when").perform(); + candidateSteps[4].createFrom(tableRow, "When a when alias").perform(); + candidateSteps[5].createFrom(tableRow, "When another when alias").perform(); + candidateSteps[6].createFrom(tableRow, "Then a then").perform(); + candidateSteps[7].createFrom(tableRow, "Then a then alias").perform(); + candidateSteps[8].createFrom(tableRow, "Then another then alias").perform(); ensureThat(steps.givens, equalTo(3)); ensureThat(steps.whens, equalTo(3)); @@ -42,12 +42,12 @@ CandidateStep[] candidateSteps = steps.getSteps(); ensureThat(candidateSteps.length, equalTo(6)); - candidateSteps[0].createFrom(tableValues, "Given a given").perform(); - candidateSteps[1].createFrom(tableValues, "Given a given alias").perform(); - candidateSteps[2].createFrom(tableValues, "When a when").perform(); - candidateSteps[3].createFrom(tableValues, "When a when alias").perform(); - candidateSteps[4].createFrom(tableValues, "Then a then").perform(); - candidateSteps[5].createFrom(tableValues, "Then a then alias").perform(); + candidateSteps[0].createFrom(tableRow, "Given a given").perform(); + candidateSteps[1].createFrom(tableRow, "Given a given alias").perform(); + candidateSteps[2].createFrom(tableRow, "When a when").perform(); + candidateSteps[3].createFrom(tableRow, "When a when alias").perform(); + candidateSteps[4].createFrom(tableRow, "Then a then").perform(); + candidateSteps[5].createFrom(tableRow, "Then a then alias").perform(); ensureThat(steps.givens, equalTo(2)); ensureThat(steps.whens, equalTo(2)); @@ -104,7 +104,7 @@ CandidateStep[] candidateSteps = steps.getSteps(); ensureThat(candidateSteps.length, equalTo(2)); - candidateSteps[0].createFrom(tableValues, "Given a given").perform(); + candidateSteps[0].createFrom(tableRow, "Given a given").perform(); }
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java (1223 => 1224)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -16,7 +16,7 @@ public class UnmatchedToPendingStepCreatorBehaviour { - private Map<String, String> tableValues = new HashMap<String, String>(); + private Map<String, String> tableRow = new HashMap<String, String>(); @Test public void shouldMatchUpStepsAndScenarioDefinitionToCreateExecutableSteps() { @@ -28,11 +28,11 @@ Step executableStep = mock(Step.class); stub(candidate.matches("my step")).toReturn(true); - stub(candidate.createFrom(tableValues, "my step")).toReturn(executableStep); + stub(candidate.createFrom(tableRow, "my step")).toReturn(executableStep); stub(steps.getSteps()).toReturn(new CandidateStep[] {candidate}); // When - Step[] executableSteps = creator.createStepsFrom(new ScenarioDefinition("", asList("my step")), tableValues, steps); + Step[] executableSteps = creator.createStepsFrom(new ScenarioDefinition("", asList("my step")), tableRow, steps); // Then ensureThat(executableSteps.length, equalTo(1)); @@ -51,7 +51,7 @@ stub(steps.getSteps()).toReturn(new CandidateStep[] {candidate}); // When - Step[] executableSteps = creator.createStepsFrom(new ScenarioDefinition("", asList("my step")), tableValues, steps); + Step[] executableSteps = creator.createStepsFrom(new ScenarioDefinition("", asList("my step")), tableRow, steps); // Then ensureThat(executableSteps.length, equalTo(1)); StepResult result = executableSteps[0].perform(); @@ -79,13 +79,13 @@ Step normalStep = mock(Step.class); stub(candidate.matches("my step")).toReturn(true); - stub(candidate.createFrom(tableValues, "my step")).toReturn(normalStep); + stub(candidate.createFrom(tableRow, "my step")).toReturn(normalStep); stub(steps1.getSteps()).toReturn(new CandidateStep[] {candidate}); stub(steps2.getSteps()).toReturn(new CandidateStep[] {}); // When we create the series of steps for the scenario UnmatchedToPendingStepCreator creator = new UnmatchedToPendingStepCreator(); - Step[] executableSteps = creator.createStepsFrom(new ScenarioDefinition("", asList("my step")), tableValues, steps1, steps2); + Step[] executableSteps = creator.createStepsFrom(new ScenarioDefinition("", asList("my step")), tableRow, steps1, steps2); // Then all before and after steps should be added ensureThat(executableSteps, array(equalTo(stepBefore2), equalTo(stepBefore1), equalTo(normalStep), equalTo(stepAfter1), equalTo(stepAfter2)));
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java (1223 => 1224)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -70,8 +70,10 @@ private void runTemplateScenario(Configuration configuration, ScenarioDefinition scenario, Table table, CandidateSteps... candidateSteps) { - for (Map<String,String> tableValues : table.getRows() ) { - runScenario(configuration, scenario, tableValues, candidateSteps); + reporter.usingTable(table); + for (Map<String,String> tableRow : table.getRows() ) { + reporter.usingTableRow(tableRow); + runScenario(configuration, scenario, tableRow, candidateSteps); } } @@ -88,12 +90,9 @@ } private void runScenario(Configuration configuration, - ScenarioDefinition scenario, Map<String, String> tableValues, CandidateSteps... candidateSteps) { - Step[] steps = configuration.forCreatingSteps().createStepsFrom(scenario, tableValues, candidateSteps); + ScenarioDefinition scenario, Map<String, String> tableRow, CandidateSteps... candidateSteps) { + Step[] steps = configuration.forCreatingSteps().createStepsFrom(scenario, tableRow, candidateSteps); reporter.beforeScenario(scenario.getTitle()); - if ( !tableValues.isEmpty() ){ - reporter.usingTableValues(tableValues); - } state = new FineSoFar(); for (Step step : steps) { state.run(step);
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java (1223 => 1224)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -5,6 +5,7 @@ import java.util.Map; import org.jbehave.scenario.definition.Blurb; +import org.jbehave.scenario.definition.Table; /** * Swallows the reports from all scenarios that pass, providing output only for @@ -112,11 +113,19 @@ } }); } + + public void usingTable(final Table table) { + currentScenario.add(new Todo() { + public void doNow() { + delegate.usingTable(table); + } + }); + } - public void usingTableValues(final Map<String, String> tableValues) { + public void usingTableRow(final Map<String, String> tableRow) { currentScenario.add(new Todo() { public void doNow() { - delegate.usingTableValues(tableValues); + delegate.usingTableRow(tableRow); } }); }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java (1223 => 1224)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -5,6 +5,7 @@ import java.util.Map; import org.jbehave.scenario.definition.Blurb; +import org.jbehave.scenario.definition.Table; /** * <p> @@ -13,69 +14,77 @@ */ public class PrintStreamScenarioReporter implements ScenarioReporter { - private final PrintStream output; - private final boolean reportErrors; - private Throwable cause; + private final PrintStream output; + private final boolean reportErrors; + private Throwable cause; - public PrintStreamScenarioReporter() { - this(System.out); - } + public PrintStreamScenarioReporter() { + this(System.out); + } - public PrintStreamScenarioReporter(PrintStream output) { - this(output, false); - } + public PrintStreamScenarioReporter(PrintStream output) { + this(output, false); + } - public PrintStreamScenarioReporter(PrintStream output, boolean reportErrors) { - this.output = output; - this.reportErrors = reportErrors; - } + public PrintStreamScenarioReporter(PrintStream output, boolean reportErrors) { + this.output = output; + this.reportErrors = reportErrors; + } - public void successful(String step) { - output.println(step); - } + public void successful(String step) { + output.println(step); + } - public void pending(String step) { - output.println(step + " (PENDING)"); - } + public void pending(String step) { + output.println(step + " (PENDING)"); + } - public void notPerformed(String step) { - output.println(step + " (NOT PERFORMED)"); - } + public void notPerformed(String step) { + output.println(step + " (NOT PERFORMED)"); + } - public void failed(String step, Throwable cause) { - this.cause = cause; - output.println(step + " (FAILED)"); - } + public void failed(String step, Throwable cause) { + this.cause = cause; + output.println(step + " (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("Scenario: " + title); - output.println(); - } + public void beforeScenario(String title) { + cause = null; + output.println("Scenario: " + title); + output.println(); + } - public void afterStory() { + public void afterStory() { - } + } - public void beforeStory(Blurb blurb) { - output.println(blurb.asString()); - output.println(); - } + public void beforeStory(Blurb blurb) { + output.println(blurb.asString()); + output.println(); + } public void givenScenarios(List<String> givenScenarios) { - output.println("GivenScenarios: "+givenScenarios); + output.println("GivenScenarios: " + givenScenarios); } - public void usingTableValues(Map<String, String> tableValues) { - output.println("Using table values: "+tableValues); + public void usingTable(Table table) { + output.println("Using table:"); + output.println(); + output.println(table); + output.println(); } + public void usingTableRow(Map<String, String> tableRow) { + output.println("Using table row: " + tableRow); + output.println(); + } + }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java (1223 => 1224)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -4,6 +4,7 @@ import java.util.Map; import org.jbehave.scenario.definition.Blurb; +import org.jbehave.scenario.definition.Table; /** * Allows the runner to report the state of running scenarios @@ -23,8 +24,10 @@ void givenScenarios(List<String> givenScenarios); - void usingTableValues(Map<String, String> tableValues); + void usingTable(Table table); + void usingTableRow(Map<String, String> tableRow); + void successful(String step); void pending(String step);
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java (1223 => 1224)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -4,6 +4,7 @@ import java.util.Map; import org.jbehave.scenario.definition.Blurb; +import org.jbehave.scenario.definition.Table; import org.jbehave.scenario.errors.StepFailure; /** @@ -66,8 +67,12 @@ delegate.givenScenarios(givenScenarios); } - public void usingTableValues(Map<String, String> tableValues) { - delegate.usingTableValues(tableValues); + public void usingTable(Table table) { + delegate.usingTable(table); } + public void usingTableRow(Map<String, String> tableRow) { + delegate.usingTableRow(tableRow); + } + }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java (1223 => 1224)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -81,7 +81,7 @@ return step.substring(word.length() + 1); // 1 for the space after } - public Step createFrom(Map<String, String> tableValues, + public Step createFrom(Map<String, String> tableRow, final String stepAsString) { String startingWord = findStartingWord(stepAsString); Matcher matcher = pattern.matcher(trimStartingWord(startingWord, @@ -90,25 +90,25 @@ Type[] types = method.getGenericParameterTypes(); String[] annotationNames = annotatedParameterNames(); String[] parameterNames = paranamer.lookupParameterNames(method, false); - Object[] args = argsForStep(tableValues, matcher, types, + Object[] args = argsForStep(tableRow, matcher, types, annotationNames, parameterNames); return createStep(stepAsString, args); } - private Object[] argsForStep(Map<String, String> tableValues, + private Object[] argsForStep(Map<String, String> tableRow, Matcher matcher, Type[] types, String[] annotationNames, String[] parameterNames) { final Object[] args = new Object[types.length]; for (int position = 0; position < types.length; position++) { String arg = argForPosition(position, annotationNames, parameterNames, - tableValues, matcher); + tableRow, matcher); args[position] = parameterConverters.convert(arg, types[position]); } return args; } private String argForPosition(int position, String[] annotationNames, - String[] parameterNames, Map<String, String> tableValues, + String[] parameterNames, Map<String, String> tableRow, Matcher matcher) { int annotatedNamePosition = parameterPosition(annotationNames, position); int parameterNamePosition = parameterPosition(parameterNames, position); @@ -123,15 +123,15 @@ stepMonitor.usingParameterNameForArg(name, position); arg = getGroup(matcher, name); } else if (annotatedNamePosition != -1 - && isTableFieldName(tableValues, annotationNames[position])) { + && isTableFieldName(tableRow, annotationNames[position])) { String name = annotationNames[position]; stepMonitor.usingTableAnnotatedNameForArg(name, position); - arg = getTableValue(tableValues, name); + arg = getTableValue(tableRow, name); } else if (parameterNamePosition != -1 - && isTableFieldName(tableValues, parameterNames[position])) { + && isTableFieldName(tableRow, parameterNames[position])) { String name = parameterNames[position]; stepMonitor.usingTableParameterNameForArg(name, position); - arg = getTableValue(tableValues, name); + arg = getTableValue(tableRow, name); } else { stepMonitor.usingNaturalOrderForArg(position); arg = matcher.group(position + 1); @@ -140,13 +140,13 @@ return arg; } - private String getTableValue(Map<String, String> tableValues, String name) { - return tableValues.get(name); + private String getTableValue(Map<String, String> tableRow, String name) { + return tableRow.get(name); } - private boolean isTableFieldName(Map<String, String> tableValues, + private boolean isTableFieldName(Map<String, String> tableRow, String name) { - return tableValues.get(name) != null; + return tableRow.get(name) != null; } private String getGroup(Matcher matcher, String name) {
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/StepCreator.java (1223 => 1224)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/StepCreator.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/StepCreator.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -11,6 +11,6 @@ public interface StepCreator { Step[] createStepsFrom(ScenarioDefinition scenarioDefinition, - Map<String, String> tableValues, CandidateSteps... candidateSteps); + Map<String, String> tableRow, CandidateSteps... candidateSteps); }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreator.java (1223 => 1224)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreator.java 2009-09-05 15:41:28 UTC (rev 1223) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreator.java 2009-09-05 15:58:21 UTC (rev 1224) @@ -12,11 +12,11 @@ public class UnmatchedToPendingStepCreator implements StepCreator { public Step[] createStepsFrom(ScenarioDefinition scenario, - Map<String, String> tableValues, + Map<String, String> tableRow, CandidateSteps... candidateSteps) { List<Step> steps = new ArrayList<Step>(); - addAllNormalSteps(scenario, steps, tableValues, candidateSteps); + addAllNormalSteps(scenario, steps, tableRow, candidateSteps); addBeforeAndAfterSteps(steps, candidateSteps); return steps.toArray(new Step[steps.size()]); @@ -34,13 +34,13 @@ } private void addAllNormalSteps(ScenarioDefinition scenarioDefinition, - List<Step> steps, Map<String, String> tableValues, CandidateSteps... candidateSteps) { + List<Step> steps, Map<String, String> tableRow, CandidateSteps... candidateSteps) { for (String stringStep : scenarioDefinition.getSteps()) { Step step = new PendingStep(stringStep); for (CandidateSteps candidates : candidateSteps) { for (CandidateStep candidate : candidates.getSteps()) { if (candidate.matches(stringStep)) { - step = candidate.createFrom(tableValues, stringStep); + step = candidate.createFrom(tableRow, stringStep); break; } }
To unsubscribe from this list please visit:
