cucumber-jvm: Confusing/misleading error creating FileOutputStream for plugin

Someone contacted me with the following stack trace:

FAILED CONFIGURATION: @BeforeClass setUpClass
java.lang.IllegalArgumentException: Couldn't create a file output stream for target\cucumber\cucumberReport.json.
Make sure the the file isn't a directory.
The details are in the stack trace below:
at io.cucumber.core.plugin.PluginFactory.createFileOutputStream(PluginFactory.java:209)
at io.cucumber.core.plugin.PluginFactory.openStream(PluginFactory.java:197)
at io.cucumber.core.plugin.PluginFactory.convert(PluginFactory.java:164)
at io.cucumber.core.plugin.PluginFactory.instantiate(PluginFactory.java:97)
at io.cucumber.core.plugin.PluginFactory.create(PluginFactory.java:62)
at io.cucumber.core.plugin.Plugins.createPlugins(Plugins.java:32)
at io.cucumber.core.plugin.Plugins.<init>(Plugins.java:25)
at io.cucumber.testng.TestNGCucumberRunner.<init>(TestNGCucumberRunner.java:92)
at io.cucumber.testng.AbstractTestNGCucumberTests.setUpClass(AbstractTestNGCucumberTests.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:63)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:348)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:302)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
at org.testng.TestNG.runSuites(TestNG.java:1039)
at org.testng.TestNG.run(TestNG.java:1007)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.io.FileNotFoundException: target\cucumber\cucumberReport.json (The system cannot find the path specified)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at io.cucumber.core.plugin.PluginFactory.createFileOutputStream(PluginFactory.java:207)
... 34 more
  • Cucumber-JVM 6.6.0
  • JDK 1.8.0_261
  • Windows

Some theories what might be wrong (without having looked at the code or tried to reproduce it):

  • The path is a directory (unlikely)
  • We’re not doing mkdir -p
  • Something to do with backslashes?
  • File permissions (unlikely on windows?)

In any case we should inspect the file system more closely when an error occurs so we can provide a better error message.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 20 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Can you try: html:target/report/cucumber.html. Note the extension.

I’m still facing this issue with 6.7.0