Skip to content

Commit

Permalink
[JUnit Platform] Support feature files with space in filename (#2521)
Browse files Browse the repository at this point in the history
Co-authored-by: Gregory Fernandez <gregory.fernandez@kosmos.fr>
  • Loading branch information
lgringo and Gregory Fernandez committed Apr 17, 2022
1 parent 367861a commit 25f7d56
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [TestNG] Remove spurious Optional\[<Feature Name>] from test name ([#2488](https://github.com/cucumber/cucumber-jvm/pull/2488) M.P. Korstanje)
* [BOM] Add missing dependencies to bill of materials ([#2496](https://github.com/cucumber/cucumber-jvm/pull/2496) M.P. Korstanje)
* [Spring] Start and stop test context once per scenario ([#2517](https://github.com/cucumber/cucumber-jvm/pull/2517) M.P. Korstanje)
* [JUnit Platform] Feature files with space in filename generate Illegal Character ([#2521](https://github.com/cucumber/cucumber-jvm/pull/2521) G. Fernandez)

## [7.2.3] (2022-01-13)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static FeatureOrigin fromUri(URI uri) {
if (!uri.getSchemeSpecificPart().startsWith("/")) {
// ClasspathResourceSource.from expects all resources to start
// with a forward slash
uri = URI.create(CLASSPATH_SCHEME_PREFIX + "/" + uri.getSchemeSpecificPart());
uri = URI.create(CLASSPATH_SCHEME_PREFIX + "/" + uri.getRawSchemeSpecificPart());
}
ClasspathResourceSource source = ClasspathResourceSource.from(uri);
return new ClasspathFeatureOrigin(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ void resolveRequestWithClasspathResourceSelector() {
assertEquals(1, testDescriptor.getChildren().size());
}

@Test
void resolveRequestWithClasspathResourceSelectorAndWithSpaceInFilename() {
DiscoverySelector resource = selectClasspathResource("io/cucumber/junit/platform/engine/with space.feature");
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(1, testDescriptor.getChildren().size());
}

@Test
void resolveRequestWithClasspathResourceSelectorAndFilePosition() {
String feature = "io/cucumber/junit/platform/engine/rule.feature";
Expand Down Expand Up @@ -120,7 +128,7 @@ void resolveRequestWithClasspathRootSelector() {
DiscoverySelector resource = selectClasspathRoots(singleton(classpathRoot)).get(0);
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(6, testDescriptor.getChildren().size());
assertEquals(7, testDescriptor.getChildren().size());
}

@Test
Expand Down Expand Up @@ -256,15 +264,15 @@ void resolveRequestWithDirectorySelector() {
DiscoverySelector resource = selectDirectory("src/test/resources/io/cucumber/junit/platform/engine");
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(5, testDescriptor.getChildren().size());
assertEquals(6, testDescriptor.getChildren().size());
}

@Test
void resolveRequestWithPackageSelector() {
DiscoverySelector resource = selectPackage("io.cucumber.junit.platform.engine");
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(5, testDescriptor.getChildren().size());
assertEquals(6, testDescriptor.getChildren().size());
}

@Test
Expand Down Expand Up @@ -397,7 +405,7 @@ void resolveRequestWithClassSelector() {
DiscoverySelector resource = selectClass(RunCucumberTest.class);
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(5, testDescriptor.getChildren().size());
assertEquals(6, testDescriptor.getChildren().size());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: A feature with a single scenario inside a file with space in filename

Scenario: A single scenario
Given a single scenario
When it is executed
Then nothing else happens

0 comments on commit 25f7d56

Please sign in to comment.