Skip to content

Commit 3fc886e

Browse files
committed
Execute no scenarios when the rerun file is empty. Fixes #840.
1 parent c72b464 commit 3fc886e

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

History.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## [1.2.3-SNAPSHOT](https://github.com/cucumber/cucumber-jvm/compare/v1.2.2...master) (In Git)
22

3-
* Snippets for quoted arguments changed from `(.*?)` to `([^\"]*)` (which is how it was before 1.1.6). See [cucumber/cucumber#63](https://github.com/cucumber/cucumber/pull/663) (Aslak Hellesøy)
3+
* Execute no scenarios when the rerun file is empty ([#840](https://github.com/cucumber/cucumber-jvm/issues/840) Björn Rasmusson)
4+
* Snippets for quoted arguments changed from `(.*?)` to `([^\"]*)` (which is how it was before 1.1.6). See [cucumber/cucumber#663](https://github.com/cucumber/cucumber/pull/663) (Aslak Hellesøy)
45
* Fix non running gradle example ([#839](https://github.com/cucumber/cucumber-jvm/pull/839) Ole Christian Langfjæran)
56

67
## [1.2.2](https://github.com/cucumber/cucumber-jvm/compare/v1.2.0...v1.2.2) (2015-01-13)

core/src/main/java/cucumber/runtime/model/CucumberFeature.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ private static void loadFromRerunFile(FeatureBuilder builder, ResourceLoader res
6262
Iterable<Resource> resources = resourceLoader.resources(rerunPath, null);
6363
for (Resource resource : resources) {
6464
String source = builder.read(resource);
65-
for (String featurePath : source.split(" ")) {
66-
loadFromFileSystemOrClasspath(builder, resourceLoader, featurePath, filters);
65+
if (!source.isEmpty()) {
66+
for (String featurePath : source.split(" ")) {
67+
loadFromFileSystemOrClasspath(builder, resourceLoader, featurePath, filters);
68+
}
6769
}
6870
}
6971
}

core/src/test/java/cucumber/runtime/model/CucumberFeatureTest.java

+31
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static java.util.Collections.emptyList;
1919
import static org.junit.Assert.assertEquals;
2020
import static org.junit.Assert.fail;
21+
import static org.mockito.Matchers.anyString;
2122
import static org.mockito.Mockito.mock;
2223
import static org.mockito.Mockito.when;
2324

@@ -116,6 +117,26 @@ public void loads_features_specified_in_rerun_file() throws Exception {
116117
assertEquals("Scenario: scenario 2", features.get(1).getFeatureElements().get(0).getVisualName());
117118
}
118119

120+
@Test
121+
public void loads_no_features_when_rerun_file_is_empty() throws Exception {
122+
String feature = "" +
123+
"Feature: bar\n" +
124+
" Scenario: scenario bar\n" +
125+
" * step\n";
126+
String rerunPath = "path/rerun.txt";
127+
String rerunFile = "";
128+
ResourceLoader resourceLoader = mockFeatureFileResourceForAnyFeaturePath(feature);
129+
mockFileResource(resourceLoader, rerunPath, null, rerunFile);
130+
131+
List<CucumberFeature> features = CucumberFeature.load(
132+
resourceLoader,
133+
asList("@" + rerunPath),
134+
new ArrayList<Object>(),
135+
new PrintStream(new ByteArrayOutputStream()));
136+
137+
assertEquals(0, features.size());
138+
}
139+
119140
@Test
120141
public void loads_features_specified_in_rerun_file_from_classpath_when_not_in_file_system() throws Exception {
121142
String featurePath = "path/bar.feature";
@@ -214,6 +235,16 @@ private ResourceLoader mockFeatureFileResource(String featurePath, String featur
214235
return resourceLoader;
215236
}
216237

238+
private ResourceLoader mockFeatureFileResourceForAnyFeaturePath(String feature)
239+
throws IOException, UnsupportedEncodingException {
240+
ResourceLoader resourceLoader = mock(ResourceLoader.class);
241+
Resource resource = mock(Resource.class);
242+
when(resource.getPath()).thenReturn("");
243+
when(resource.getInputStream()).thenReturn(new ByteArrayInputStream(feature.getBytes("UTF-8")));
244+
when(resourceLoader.resources(anyString(), anyString())).thenReturn(asList(resource));
245+
return resourceLoader;
246+
}
247+
217248
private void mockFeatureFileResource(ResourceLoader resourceLoader, String featurePath, String feature)
218249
throws IOException, UnsupportedEncodingException {
219250
mockFileResource(resourceLoader, featurePath, ".feature", feature);

0 commit comments

Comments
 (0)