Skip to content

Use "uri" instead of "path" to reference feature files. #1179

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
Jul 14, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ public void setNumberOfTests(final int numberOfTests) {
}

void testSourceRead(final TestSourceRead event) {
testSources.addTestSourceReadEvent(event.path, event);
testSources.addTestSourceReadEvent(event.uri, event);
}

void startTestCase(final TestCase testCase) {
if (!testCase.getPath().equals(currentUri)) {
currentUri = testCase.getPath();
if (!testCase.getUri().equals(currentUri)) {
currentUri = testCase.getUri();
currentFeatureName = testSources.getFeatureName(currentUri);
}
currentTestCaseName = testCase.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class AndroidInstrumentationReporterTest {

@Before
public void beforeEachTest() {
when(testCase.getPath()).thenReturn("path/file.feature");
when(testCase.getUri()).thenReturn("path/file.feature");
when(testCase.getName()).thenReturn("Some important scenario");
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/cucumber/api/CucumberOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
boolean strict() default false;

/**
* @return the paths to the feature(s)
* @return the uris to the feature(s)
*/
String[] features() default {};

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/cucumber/api/TestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String getScenarioDesignation() {
return fileColonLine(pickleEvent.pickle.getLocations().get(0)) + " # " + getName();
}

public String getPath() {
public String getUri() {
return pickleEvent.uri;
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/cucumber/api/event/TestSourceRead.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package cucumber.api.event;

public final class TestSourceRead extends TimeStampedEvent {
public final String path;
public final String uri;
public final String language;
public final String source;

public TestSourceRead(Long timeStamp, String path, String language, String source) {
public TestSourceRead(Long timeStamp, String uri, String language, String source) {
super(timeStamp);
this.path = path;
this.uri = uri;
this.language = language;
this.source = source;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/cucumber/runtime/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void runFeature(CucumberFeature feature) {
public List<PickleEvent> compileFeature(CucumberFeature feature) {
List<PickleEvent> pickleEvents = new ArrayList<PickleEvent>();
for (Pickle pickle : compiler.compile(feature.getGherkinFeature())) {
pickleEvents.add(new PickleEvent(feature.getPath(), pickle));
pickleEvents.add(new PickleEvent(feature.getUri(), pickle));
}
return pickleEvents;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class UndefinedStepsTracker implements EventListener {
private EventHandler<TestSourceRead> testSourceReadHandler = new EventHandler<TestSourceRead>() {
@Override
public void receive(TestSourceRead event) {
pathToSourceMap.put(event.path, event.source);
pathToSourceMap.put(event.uri, event.source);
}
};
private EventHandler<SnippetsSuggestedEvent> snippetsSuggestedHandler = new EventHandler<SnippetsSuggestedEvent>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void setEventPublisher(EventPublisher publisher) {
}

private void handleTestSourceRead(TestSourceRead event) {
testSources.addTestSourceReadEvent(event.path, event);
testSources.addTestSourceReadEvent(event.uri, event);
}

private void handleTestCaseStarted(TestCaseStarted event) {
Expand Down Expand Up @@ -208,16 +208,16 @@ private void finishReport() {
}

private void handleStartOfFeature(TestCase testCase) {
if (currentFeatureFile == null || !currentFeatureFile.equals(testCase.getPath())) {
currentFeatureFile = testCase.getPath();
if (currentFeatureFile == null || !currentFeatureFile.equals(testCase.getUri())) {
currentFeatureFile = testCase.getUri();
jsFunctionCall("uri", currentFeatureFile);
jsFunctionCall("feature", createFeature(testCase));
}
}

private Map<String, Object> createFeature(TestCase testCase) {
Map<String, Object> featureMap = new HashMap<String, Object>();
Feature feature = testSources.getFeature(testCase.getPath());
Feature feature = testSources.getFeature(testCase.getUri());
if (feature != null) {
featureMap.put("keyword", feature.getKeyword());
featureMap.put("name", feature.getName());
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/cucumber/runtime/formatter/JSONFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ public void setEventPublisher(EventPublisher publisher) {
}

private void handleTestSourceRead(TestSourceRead event) {
testSources.addTestSourceReadEvent(event.path, event);
testSources.addTestSourceReadEvent(event.uri, event);
}

private void handleTestCaseStarted(TestCaseStarted event) {
if (currentFeatureFile == null || !currentFeatureFile.equals(event.testCase.getPath())) {
currentFeatureFile = event.testCase.getPath();
if (currentFeatureFile == null || !currentFeatureFile.equals(event.testCase.getUri())) {
currentFeatureFile = event.testCase.getUri();
Map<String, Object> currentFeatureMap = createFeatureMap(event.testCase);
featureMaps.add(currentFeatureMap);
currentElementsList = (List<Map<String, Object>>) currentFeatureMap.get("elements");
Expand Down Expand Up @@ -160,9 +160,9 @@ private void finishReport() {

private Map<String, Object> createFeatureMap(TestCase testCase) {
Map<String, Object> featureMap = new HashMap<String, Object>();
featureMap.put("uri", testCase.getPath());
featureMap.put("uri", testCase.getUri());
featureMap.put("elements", new ArrayList<Map<String, Object>>());
Feature feature = testSources.getFeature(testCase.getPath());
Feature feature = testSources.getFeature(testCase.getUri());
if (feature != null) {
featureMap.put("keyword", feature.getKeyword());
featureMap.put("name", feature.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ public void setEventPublisher(EventPublisher publisher) {
}

private void handleTestSourceRead(TestSourceRead event) {
TestCase.testSources.addTestSourceReadEvent(event.path, event);
TestCase.testSources.addTestSourceReadEvent(event.uri, event);
}

private void handleTestCaseStarted(TestCaseStarted event) {
if (TestCase.currentFeatureFile == null || !TestCase.currentFeatureFile.equals(event.testCase.getPath())) {
TestCase.currentFeatureFile = event.testCase.getPath();
if (TestCase.currentFeatureFile == null || !TestCase.currentFeatureFile.equals(event.testCase.getUri())) {
TestCase.currentFeatureFile = event.testCase.getUri();
TestCase.previousTestCaseName = "";
TestCase.exampleNumber = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void setMonochrome(boolean monochrome) {
}

private void handleTestSourceRead(TestSourceRead event) {
testSources.addTestSourceReadEvent(event.path, event);
testSources.addTestSourceReadEvent(event.uri, event);
}

private void handleTestCaseStarted(TestCaseStarted event) {
Expand Down Expand Up @@ -155,11 +155,11 @@ private void finishReport() {
}

private void handleStartOfFeature(TestCaseStarted event) {
if (currentFeatureFile == null || !currentFeatureFile.equals(event.testCase.getPath())) {
if (currentFeatureFile == null || !currentFeatureFile.equals(event.testCase.getUri())) {
if (currentFeatureFile != null) {
out.println();
}
currentFeatureFile = event.testCase.getPath();
currentFeatureFile = event.testCase.getUri();
printFeature(currentFeatureFile);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void handleTestRunFinished() {
}

private void recordTestFailed(TestCase testCase) {
String path = testCase.getPath();
String path = testCase.getUri();
ArrayList<Integer> failedTestCases = this.featureAndFailedLinesMapping.get(path);
if (failedTestCases == null) {
failedTestCases = new ArrayList<Integer>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ public void setStrict(boolean strict) {
}

private void handleTestSourceRead(TestSourceRead event) {
TestMethod.testSources.addTestSourceReadEvent(event.path, event);
TestMethod.testSources.addTestSourceReadEvent(event.uri, event);
}

private void handleTestCaseStarted(TestCaseStarted event) {
if (TestMethod.currentFeatureFile == null || !TestMethod.currentFeatureFile.equals(event.testCase.getPath())) {
TestMethod.currentFeatureFile = event.testCase.getPath();
if (TestMethod.currentFeatureFile == null || !TestMethod.currentFeatureFile.equals(event.testCase.getUri())) {
TestMethod.currentFeatureFile = event.testCase.getUri();
TestMethod.previousTestCaseName = "";
TestMethod.exampleNumber = 1;
clazz = document.createElement("class");
clazz.setAttribute("name", TestMethod.testSources.getFeature(event.testCase.getPath()).getName());
clazz.setAttribute("name", TestMethod.testSources.getFeature(event.testCase.getUri()).getName());
test.appendChild(clazz);
}
root = document.createElement("test-method");
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/cucumber/runtime/model/CucumberFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class CucumberFeature implements Serializable {
private static final long serialVersionUID = 1L;
private final String path;
private final String uri;
private String language;
private GherkinDocument gherkinDocument;
private String gherkinSource;
Expand Down Expand Up @@ -117,9 +117,9 @@ private static void loadFromFeaturePath(FeatureBuilder builder, ResourceLoader r
}
}

public CucumberFeature(GherkinDocument gherkinDocument, String path, String gherkinSource) {
public CucumberFeature(GherkinDocument gherkinDocument, String uri, String gherkinSource) {
this.gherkinDocument = gherkinDocument;
this.path = path;
this.uri = uri;
this.gherkinSource = gherkinSource;
if (gherkinDocument.getFeature() != null) {
setLanguage(gherkinDocument.getFeature().getLanguage());
Expand All @@ -134,12 +134,12 @@ public String getLanguage() {
return language;
}

public String getPath() {
return path;
public String getUri() {
return uri;
}

public void sendTestSourceRead(EventBus bus) {
bus.send(new TestSourceRead(bus.getTime(), path, gherkinDocument.getFeature().getLanguage(), gherkinSource));
bus.send(new TestSourceRead(bus.getTime(), uri, gherkinDocument.getFeature().getLanguage(), gherkinSource));
}

private void setLanguage(String language) {
Expand All @@ -149,7 +149,7 @@ private void setLanguage(String language) {
private static class CucumberFeatureUriComparator implements Comparator<CucumberFeature> {
@Override
public int compare(CucumberFeature a, CucumberFeature b) {
return a.getPath().compareTo(b.getPath());
return a.getUri().compareTo(b.getUri());
}
}
}
4 changes: 2 additions & 2 deletions core/src/test/java/cucumber/runtime/FeatureBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void works_when_path_and_uri_are_the_same() throws IOException {
builder.parse(resource);

assertEquals(1, features.size());
assertEquals(featurePath, features.get(0).getPath());
assertEquals(featurePath, features.get(0).getUri());
}

@Test
Expand All @@ -54,7 +54,7 @@ public void converts_windows_path_to_forward_slash() throws IOException {
builder.parse(resource);

assertEquals(1, features.size());
assertEquals("path/foo.feature", features.get(0).getPath());
assertEquals("path/foo.feature", features.get(0).getUri());
}

private Resource createResourceMock(String featurePath) throws IOException {
Expand Down
4 changes: 2 additions & 2 deletions junit/src/main/java/cucumber/runtime/junit/FeatureRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void buildFeatureElementRunners(Runtime runtime, JUnitReporter jUnitRepo
Compiler compiler = new Compiler();
List<PickleEvent> pickleEvents = new ArrayList<PickleEvent>();
for (Pickle pickle : compiler.compile(cucumberFeature.getGherkinFeature())) {
pickleEvents.add(new PickleEvent(cucumberFeature.getPath(), pickle));
pickleEvents.add(new PickleEvent(cucumberFeature.getUri(), pickle));
}
Feature feature = cucumberFeature.getGherkinFeature().getFeature();
String featureName = feature.getName();
Expand Down Expand Up @@ -105,7 +105,7 @@ private static final class FeatureId implements Serializable {
private final String uri;

FeatureId(CucumberFeature feature) {
this.uri = feature.getPath();
this.uri = feature.getUri();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInASc
Compiler compiler = new Compiler();
List<PickleEvent> pickleEvents = new ArrayList<PickleEvent>();
for (Pickle pickle : compiler.compile(features.getGherkinFeature())) {
pickleEvents.add(new PickleEvent(features.getPath(), pickle));
pickleEvents.add(new PickleEvent(features.getUri(), pickle));
};

WithStepDescriptions runner = (WithStepDescriptions) PickleRunners.withStepDescriptions(
Expand Down Expand Up @@ -78,7 +78,7 @@ public void shouldAssignUnequalDescriptionsToDifferentStepsInAScenarioOutline()
Compiler compiler = new Compiler();
List<PickleEvent> pickleEvents = new ArrayList<PickleEvent>();
for (Pickle pickle : compiler.compile(features.getGherkinFeature())) {
pickleEvents.add(new PickleEvent(features.getPath(), pickle));
pickleEvents.add(new PickleEvent(features.getUri(), pickle));
};

WithStepDescriptions runner = (WithStepDescriptions) PickleRunners.withStepDescriptions(
Expand Down Expand Up @@ -110,7 +110,7 @@ public void shouldIncludeScenarioNameAsClassNameInStepDescriptions() throws Exce
Compiler compiler = new Compiler();
List<PickleEvent> pickleEvents = new ArrayList<PickleEvent>();
for (Pickle pickle : compiler.compile(features.getGherkinFeature())) {
pickleEvents.add(new PickleEvent(features.getPath(), pickle));
pickleEvents.add(new PickleEvent(features.getUri(), pickle));
}

PickleRunner runner = PickleRunners.withStepDescriptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static List<PickleEvent> pickleEventsFromFeature(final String path, final String

CucumberFeature feature = parseFeature(path, source);
for (Pickle pickle : compiler.compile(feature.getGherkinFeature())) {
pickleEvents.add(new PickleEvent(feature.getPath(), pickle));
pickleEvents.add(new PickleEvent(feature.getUri(), pickle));
};
return pickleEvents;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void close() {
public void runCukes() {
System.err.println("WARNING: The TestNGCucumberRunner.runCukes() is deprecated. Please create a runner class by subclassing AbstractTestNGCucumberTest.");
for (CucumberFeature cucumberFeature : getFeatures()) {
reporter.uri(cucumberFeature.getPath());
reporter.uri(cucumberFeature.getUri());
runtime.runFeature(cucumberFeature);
}
finish();
Expand All @@ -71,7 +71,7 @@ public void runCukes() {

public void runCucumber(CucumberFeature cucumberFeature) {
resultListener.startFeature();
reporter.uri(cucumberFeature.getPath());
reporter.uri(cucumberFeature.getUri());
runtime.runFeature(cucumberFeature);

if (!resultListener.isPassed()) {
Expand Down