|
| 1 | +package cucumber.junit; |
| 2 | + |
| 3 | +import static org.junit.Assert.*; |
| 4 | + |
| 5 | +import gherkin.formatter.model.Step; |
| 6 | + |
| 7 | +import java.util.Arrays; |
| 8 | +import java.util.Collections; |
| 9 | +import java.util.List; |
| 10 | + |
| 11 | +import org.junit.Test; |
| 12 | + |
| 13 | +import cucumber.io.ClasspathResourceLoader; |
| 14 | +import cucumber.runtime.model.CucumberFeature; |
| 15 | +import cucumber.runtime.model.CucumberScenario; |
| 16 | + |
| 17 | +public class ExecutionUnitRunnerTest { |
| 18 | + @Test |
| 19 | + public void shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario() throws Exception { |
| 20 | + List<CucumberFeature> features = |
| 21 | + CucumberFeature.load( |
| 22 | + new ClasspathResourceLoader(this.getClass().getClassLoader()), |
| 23 | + Arrays.asList(new String[] { "cucumber/junit/feature_with_same_steps_in_scenario.feature" }), |
| 24 | + Collections.emptyList()); |
| 25 | + |
| 26 | + ExecutionUnitRunner runner = |
| 27 | + new ExecutionUnitRunner( |
| 28 | + null, |
| 29 | + (CucumberScenario)features.get(0).getFeatureElements().get(0), |
| 30 | + null); |
| 31 | + |
| 32 | + // fish out the two occurrences of the same step and check whether we really got them |
| 33 | + Step stepOccurrence1 = runner.getChildren().get(0); |
| 34 | + Step stepOccurrence2 = runner.getChildren().get(2); |
| 35 | + assertEquals(stepOccurrence1.getName(), stepOccurrence2.getName()); |
| 36 | + |
| 37 | + assertFalse("Descriptions must not be equal.", |
| 38 | + runner.describeChild(stepOccurrence1) |
| 39 | + .equals(runner.describeChild(stepOccurrence2))); |
| 40 | + } |
| 41 | +} |
0 commit comments