IllegalArgumentException path must exist when the path has spaces and the URI has replaced the space with %20 url encoded
See original GitHub issueWhen the path, in my case project path, has spaces. the below error observed
[ERROR] setUpClass(common.TestRunner) Time elapsed: 2.057 s <<< FAILURE!
java.lang.IllegalArgumentException: path must exist: /Users/edmundofigueroa/projects/test test test/automation-testcases-mobile/features
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] TestRunner>AbstractTestNGCucumberTests.setUpClass:27 » IllegalArgument path mu...
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[ERROR] There are test failures.
using cucumber-testng 7.6.1
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>7.6.1</version>
</dependency>
In debugging mode, I could see that the exception is thrown in cucumber-core-7.6.0.jar,
package io.cucumber.core.resource
ResourceScanner class > scanForResourcesUri(URI classpathResourceUri)
// classpathResourceUri = file:/Users/edmundofigueroa/projects/test%20test%20test/automation-testcases-mobile/features
the spaces are replaced by %20 which is url encoded space
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Illegal character in path at index 16 [duplicate] - Stack Overflow
I'd say it doesn't like the space in the path. You can percent encode special characters like spaces. Replace it with a %20...
Read more >URL from string with spaces in it | Apple Developer Forums
You should escape the spaces. To do that, you can either change the spaces to "%20" or "+". ... You can shrink the...
Read more >HttpUrl - OkHttp - Square Open Source
Unlike host, port, path, and query the fragment is not sent to the webserver: it's private to the client. Encoding¶. Each component must...
Read more >Space in URL is getting encoded differently ... - Microsoft Learn
We are navigating to URL and URL contains a space is shown as below: ... machine 1: edge browser url showed www.google.com%20www.oracle.com
Read more >URI (Java Platform SE 7 ) - Oracle Help Center
A hierarchical URI always has a path (though it may be empty) and a ... The space character, for example, is quoted by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe you are mistaken here. Note that
scanForResourcesUri
takes aURI
as an argument. Spaces are not legal characters in a URI and so must be encoded:https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/net/URI.html
So while your project may not work with spaces in the path, it may not work for a different reason.
Now I’ve tried to reproduce your project but unfortunately I seem to be unable to. Could you please provide a minimal reproducer in the form of a github repo? You can use https://github.com/cucumber/cucumber-java-skeleton as a starting point.
@figuedmundo what was your resolution to this?