-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Confusing/misleading error creating FileOutputStream for plugin #2108
Comments
Without a reproducer or some triangulation it'd say it's impossible to tell. The javadoc for
So for example do any of these paths work:
And do any of the above paths work when the file/folders already exists?
No. We are creating the parent directories:
|
If I am using cucumber version 5.5.0 the plugin @CucumberOptions is working fine with So I simply mention But why it is giving such error to not allowing to create a new directory inside the target folder by just upgrading the version, don't know. |
That's useful information @ITMANUPAM - hopefully it will make it easier to identify the problem. We did touch this code recently, so I would not be surprised if a regression snuck in! |
Replaced `TempDir` utility with `@TempDir` from JUnit 5 and Javas path API. See: #2108
…tFile) While `makeDirs` makes an attempt at creating the directories `createDirectories` will throw an exception when the directories could not be created or if the file exists but was not a directory. See: #2108
I can't reproduce this on Windows 7. If someone can debug However I'm guessing that |
Replaced `TempDir` utility with `@TempDir` from JUnit 5 and Javas path API. See: #2108
…tFile) While `makeDirs` makes an attempt at creating the directories `createDirectories` will throw an exception when the directories could not be created or if the file exists but was not a directory. See: #2108
@aslakhellesoy @ITMANUPAM with v6.6.1 released, could you please try and see if that resolved the issue. |
Closing this due to a lack of feedback. Feel free to reopen with more information. |
I'm still facing this issue with 6.7.0 |
@mvalle I'm afraid that doesn't help much. Could you debug |
Still facing this with all 6.x.x releases. Currently trying 6.8.1, and it's the same as when I tried it on 6.0.0. @mpkorstanje
The root cause is the same as the in the original post, but I've seen various different error messages throughout trying various 6.x.x releases Here's the reference code:
In 5.x.x, the report is (correctly, and expectedly) generated target/report/ (report is a DIRECTORY) and it contains the following files: while target/cucumber contains In 6.x.x (and specifically 6.8.1): the generated file is target/cucumber (where cucumber is a FILE, not a DIRECTORY) Using
appears to solve the problem BUT THERE'S ANOTHER PROBLEM (to which I have not found a solution).
I get the original poster's problem: java.lang.IllegalArgumentException: Couldn't create parent directories of target/report/cucumber.json. Caused by: java.nio.file.FileAlreadyExistsException: /target/report So I have to stick with cucumber-jvm 5.7.0 for now. |
Can you try: |
yup! cucumber-jvm:6.8.1 works the above suggestion^ Now I have:
I no longer get java.lang.IllegalArgumentException: Couldn't create parent directories of target/report/cucumber.json. It seems from 5.x.x -> 6.x.x the change for HTML report is that the html plugin now creates a single .html file, instead of 5 files (formatter.js index.html jquery-3.4.1.min.js report.js style.css). Thus it expects to create a file, not a directory with files anymore. |
That's in the change log. But note that it's not the same problem as the @ITMANUPAM mentioned which involves the json plugin. |
Mmh. I guess they could be related if the html plugin goed first. Shows the importance of creating an MCVE. |
Cucumber v6 introduced a new html formatter. This formatter writes to a file rather then a directory[1]. However a typical use to ensure all files and up in a single folder would be `plugin=json:target/cucumber/report.json, html:target/cucumber`. So depending on the order this results in Cucumber being unable to either create the `target/cucumber` as file for the html report or `target/cucumber` as a directory for the json report. The improved error message should point this out. Fixes: #2108 Additionally the PluginFactory tests were rewritten to make them follow the arrange-act-test pattern. 1. https://github.com/cucumber/cucumber-jvm/blob/main/release-notes/v6.0.0.md#improved-html-formatter
Cucumber v6 introduced a new html formatter. This formatter writes to a file rather then a directory[1]. However a typical use to ensure all files and up in a single folder would be `plugin=json:target/cucumber/report.json, html:target/cucumber`. So depending on the order this results in Cucumber being unable to either create the `target/cucumber` as file for the html report or `target/cucumber` as a directory for the json report. The improved error message should point this out. Fixes: #2108 Additionally the PluginFactory tests were rewritten to make them follow the arrange-act-test pattern. 1. https://github.com/cucumber/cucumber-jvm/blob/main/release-notes/v6.0.0.md#improved-html-formatter
Cucumber v6 introduced a new html formatter. This formatter writes to a file rather then a directory[1]. However a typical use to ensure all files and up in a single folder would be `plugin=json:target/cucumber/report.json, html:target/cucumber`. So depending on the order this results in Cucumber being unable to either create the `target/cucumber` as file for the html report or `target/cucumber` as a directory for the json report. The improved error message should point this out. Fixes: #2108 Additionally the PluginFactory tests were rewritten to make them follow the arrange-act-test pattern. 1. https://github.com/cucumber/cucumber-jvm/blob/main/release-notes/v6.0.0.md#improved-html-formatter
Hi @mpkorstanje , after upgrading Cucumber from 6.3.0 to 6.11.0, I'm facing the same issue. I'm on Mac, but our build machines are Windows machines, and both have the same issue. I can reliably reproduce it: I've checked the file it's trying to read (/Users/erikpragt/projects/pks/rippledown/userneeds/build/run/build/test-results/junit.xml), but that file doesn't exist (yet). This is coming from our Cucumber arguments:
If I change the above to this:
Then the test passes, so it seems that something doesn't work well with directory creations. I did some more debugging, and at that line, if I do:
So, it seems that something creates this However, when I check the directory using my terminal, I see this:
So, it seems test-results is directory after all? Anything I can do to help debugging this issue? |
I could reproduce this issue with Windows 10 Enterprise, Oracle JDK1.8.0_301, cucumber 6.8.1 and 6.11.0 When debugging the code of io.cucumber.core.plugin.PluginFactory#createFileOutputStream() as described I had these findings:
Seems that this issue could be easily fixed by using FileOutputStream(canonicalFile) in line 237. |
What was the difference between the two? |
file = "target/cucumber-reports/cucumber.html" (as in @CucumberOptions) The maven project folder being the current directory, they describe the same file. |
That's odd.
I don't have a windows system available to test this with. Would you be able to make this change and test it yourself? |
The exception is thrown in some native code. I'll do the change, test it and create a pull request. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two months if no further activity occurs. |
Someone contacted me with the following stack trace:
Some theories what might be wrong (without having looked at the code or tried to reproduce it):
In any case we should inspect the file system more closely when an error occurs so we can provide a better error message.
The text was updated successfully, but these errors were encountered: