Skip to content

Commit 8ab1977

Browse files
committed
Fix failing test. Format code. Convert CRLF to LF.
1 parent f950be5 commit 8ab1977

File tree

6 files changed

+68
-63
lines changed

6 files changed

+68
-63
lines changed

junit/pom.xml

+11
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,16 @@
2727
<artifactId>junit</artifactId>
2828
<scope>provided</scope>
2929
</dependency>
30+
<!-- These dependencies are required in order to find classes when running in an IDE - they haven't been jar-jarred -->
31+
<dependency>
32+
<groupId>com.thoughtworks.xstream</groupId>
33+
<artifactId>xstream</artifactId>
34+
<scope>test</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>com.googlecode.java-diff-utils</groupId>
38+
<artifactId>diffutils</artifactId>
39+
<scope>test</scope>
40+
</dependency>
3041
</dependencies>
3142
</project>

junit/src/test/java/cucumber/junit/CucumberTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public void ensureOriginalDirectory() {
3333
@Test
3434
public void finds_features_based_on_implicit_package() throws IOException, InitializationError {
3535
Cucumber cucumber = new Cucumber(ImplicitPackage.class);
36-
assertEquals(1, cucumber.getChildren().size());
36+
assertEquals(2, cucumber.getChildren().size());
3737
assertEquals("Feature: In cucumber.junit", cucumber.getChildren().get(0).getName());
3838
}
3939

4040
@Test
4141
public void finds_features_based_on_explicit_root_package() throws IOException, InitializationError {
4242
Cucumber cucumber = new Cucumber(ExplicitPackage.class);
43-
assertEquals(1, cucumber.getChildren().size());
43+
assertEquals(2, cucumber.getChildren().size());
4444
assertEquals("Feature: In cucumber.junit", cucumber.getChildren().get(0).getName());
4545
}
4646

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

junit/src/test/java/cucumber/junit/JUnitReporterTest.java

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
package cucumber.junit;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.mockito.Mockito.mock;
5-
import static org.mockito.Mockito.verify;
6-
import static org.mockito.Mockito.when;
7-
3+
import gherkin.formatter.Formatter;
4+
import gherkin.formatter.Reporter;
5+
import gherkin.formatter.model.Result;
86
import org.junit.Before;
97
import org.junit.Test;
108
import org.junit.runner.Description;
119
import org.junit.runner.notification.Failure;
1210
import org.junit.runner.notification.RunNotifier;
1311
import org.mockito.ArgumentCaptor;
1412

15-
import gherkin.formatter.Formatter;
16-
import gherkin.formatter.Reporter;
17-
import gherkin.formatter.model.Result;
13+
import static org.junit.Assert.assertEquals;
14+
import static org.mockito.Mockito.mock;
15+
import static org.mockito.Mockito.verify;
16+
import static org.mockito.Mockito.when;
1817

19-
public class JUnitReporterTest
20-
{
18+
public class JUnitReporterTest {
2119

2220
private JUnitReporter jUnitReporter;
2321

2422
@Before
25-
public void setUp()
26-
{
23+
public void setUp() {
2724
Formatter formatter = mock(Formatter.class);
2825
Reporter reporter = mock(Reporter.class);
29-
26+
3027
jUnitReporter = new JUnitReporter(reporter, formatter);
3128
}
3229

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Feature: Scenario with same step occurring twice
2-
Scenario:
3-
When foo
4-
Then bar
5-
6-
When foo
7-
Then baz
1+
Feature: Scenario with same step occurring twice
2+
Scenario:
3+
When foo
4+
Then bar
5+
6+
When foo
7+
Then baz

junit/src/test/resources/in_root.feature

Whitespace-only changes.

0 commit comments

Comments
 (0)