Skip to content

Commit

Permalink
Fix failing test. Format code. Convert CRLF to LF.
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Feb 21, 2012
1 parent f950be5 commit 8ab1977
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 63 deletions.
11 changes: 11 additions & 0 deletions junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,16 @@
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
<!-- These dependencies are required in order to find classes when running in an IDE - they haven't been jar-jarred -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.java-diff-utils</groupId>
<artifactId>diffutils</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
4 changes: 2 additions & 2 deletions junit/src/test/java/cucumber/junit/CucumberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public void ensureOriginalDirectory() {
@Test
public void finds_features_based_on_implicit_package() throws IOException, InitializationError {
Cucumber cucumber = new Cucumber(ImplicitPackage.class);
assertEquals(1, cucumber.getChildren().size());
assertEquals(2, cucumber.getChildren().size());
assertEquals("Feature: In cucumber.junit", cucumber.getChildren().get(0).getName());
}

@Test
public void finds_features_based_on_explicit_root_package() throws IOException, InitializationError {
Cucumber cucumber = new Cucumber(ExplicitPackage.class);
assertEquals(1, cucumber.getChildren().size());
assertEquals(2, cucumber.getChildren().size());
assertEquals("Feature: In cucumber.junit", cucumber.getChildren().get(0).getName());
}

Expand Down
79 changes: 38 additions & 41 deletions junit/src/test/java/cucumber/junit/ExecutionUnitRunnerTest.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
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)));
}
}
package cucumber.junit;

import cucumber.io.ClasspathResourceLoader;
import cucumber.runtime.model.CucumberFeature;
import cucumber.runtime.model.CucumberScenario;
import gherkin.formatter.model.Step;
import org.junit.Test;

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

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

public class ExecutionUnitRunnerTest {
@Test
public void shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario() throws Exception {
List<CucumberFeature> features = CucumberFeature.load(
new ClasspathResourceLoader(this.getClass().getClassLoader()),
asList("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)));
}
}
23 changes: 10 additions & 13 deletions junit/src/test/java/cucumber/junit/JUnitReporterTest.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
package cucumber.junit;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import gherkin.formatter.Formatter;
import gherkin.formatter.Reporter;
import gherkin.formatter.model.Result;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
import org.mockito.ArgumentCaptor;

import gherkin.formatter.Formatter;
import gherkin.formatter.Reporter;
import gherkin.formatter.model.Result;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class JUnitReporterTest
{
public class JUnitReporterTest {

private JUnitReporter jUnitReporter;

@Before
public void setUp()
{
public void setUp() {
Formatter formatter = mock(Formatter.class);
Reporter reporter = mock(Reporter.class);

jUnitReporter = new JUnitReporter(reporter, formatter);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Scenario with same step occurring twice
Scenario:
When foo
Then bar
When foo
Then baz
Feature: Scenario with same step occurring twice
Scenario:
When foo
Then bar

When foo
Then baz
Empty file.

0 comments on commit 8ab1977

Please sign in to comment.