Skip to content

Fixed issue #211. #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion junit/src/main/java/cucumber/junit/ExecutionUnitRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public String getName() {

@Override
protected Description describeChild(Step step) {
return Description.createSuiteDescription(step.getKeyword() + step.getName() + "(" + getName() + ")");
int stepNumber = cucumberScenario.getSteps().indexOf(step);
return Description.createSuiteDescription(step.getKeyword() + step.getName() + "(" + getName() + ", Step: " + stepNumber + ")");
}

@Override
Expand Down
41 changes: 41 additions & 0 deletions junit/src/test/java/cucumber/junit/ExecutionUnitRunnerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cucumber.junit;

import static org.junit.Assert.*;

import gherkin.formatter.model.Step;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.junit.Test;

import cucumber.io.ClasspathResourceLoader;
import cucumber.runtime.model.CucumberFeature;
import cucumber.runtime.model.CucumberScenario;

public class ExecutionUnitRunnerTest {
@Test
public void shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario() throws Exception {
List<CucumberFeature> features =
CucumberFeature.load(
new ClasspathResourceLoader(this.getClass().getClassLoader()),
Arrays.asList(new String[] { "cucumber/junit/feature_with_same_steps_in_scenario.feature" }),
Collections.emptyList());

ExecutionUnitRunner runner =
new ExecutionUnitRunner(
null,
(CucumberScenario)features.get(0).getFeatureElements().get(0),
null);

// fish out the two occurrences of the same step and check whether we really got them
Step stepOccurrence1 = runner.getChildren().get(0);
Step stepOccurrence2 = runner.getChildren().get(2);
assertEquals(stepOccurrence1.getName(), stepOccurrence2.getName());

assertFalse("Descriptions must not be equal.",
runner.describeChild(stepOccurrence1)
.equals(runner.describeChild(stepOccurrence2)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Scenario with same step occurring twice
Scenario:
When foo
Then bar

When foo
Then baz