prashant-ramcharan / courgette-jvm

Multiprocess | Parallel Cucumber-JVM | Parallelize your Java Cucumber tests on a feature level or on a scenario level.
MIT License
131 stars 38 forks source link

java.io.IOException: Cannot run program "java": CreateProcess error=206, The filename or extension is too long #250

Closed kawalbhatia closed 3 years ago

kawalbhatia commented 3 years ago

Getting the error : java.io.IOException: Cannot run program "java": CreateProcess error=206, The filename or extension is too long

I am using Maven to build and test . when i am executing the runner file without Courgette option, it works well without any issue. However with Courgette option, it gives this error.

Tried following the steps in below link but not working: https://maven.apache.org/surefire/maven-surefire-plugin/examples/class-loading.html

prashant-ramcharan commented 3 years ago

@kawalbhatia The CreateProcess error=206 is a limitation in Windows operating systems that causes Courgette to fail when the class path exceeds the command length.

I just released Courgette version 5.9.2 which includes a new Courgette option classPath which should workaround this Windows limitation.

Refer to the example project here: https://github.com/prashant-ramcharan/courgette-jvm-classpath-example

kawalbhatia commented 3 years ago

@prashant-ramcharan _ i tried using the classpath option. It is giving this error : I have used the plugin to copy the dependencies in target/lib folder.

Created at 2021-02-01T12:48:05.037

Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream 'Error: Could not find or load main class io.cucumber.core.cli.Main'. java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command 'Error: Could not find or load main class io.cucumber.core.cli.Main'. at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.(ForkClient.java:507) at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210) at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177) at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88) at java.lang.Thread.run(Thread.java:748)

prashant-ramcharan commented 3 years ago

This suggests that you may have incorrectly configured the classpath.

Please see the example project on how to configure it correctly.

Can you paste your runner and pom.xml here?

kawalbhatia commented 3 years ago

Hi @prashant-ramcharan ,

Please find below the runner file I am using. And also attached is the pom.xml file ( attaching zip format as it is not allowing directly)

pom.zip

package paralelrunner;

import courgette.api.CourgetteOptions; import courgette.api.CourgetteRunLevel; import courgette.api.CucumberOptions; import courgette.api.testng.TestNGCourgette;

import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test;

import com.cucumber.uvs.ecom.helper.reporter.ReporterUtil; import com.cucumber.uvs.ecom.test.stepdefinition.BaseStepClass;

@Test @CourgetteOptions( threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, showTestOutput = true, reportTargetDir = "build", classPath = {"target/libs/*", "target/test-classes/"}, reportTitle = "Test - Automation Report", // environmentInfo = "browser=chrome; git_branch=master; project_info=Courgette-JVM is awesome!", plugin = "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:", cucumberOptions = @CucumberOptions(features = "src/test/resources/featurefile", glue = { "classpath:com.cucumber.uvs.ecom.test.stepdefinition", "classpath:com.cucumber.uvs.ecom.helper" }, plugin = { "pretty", "json:target/UVSEComm.json", "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:" }, monochrome = true, tags = "@RegressionGUItest"))

public class FeatureSuite extends TestNGCourgette {

@AfterClass(alwaysRun = true)
public static void writeExtentReport() {
    ReporterUtil.archiveReport();
}

@BeforeSuite(alwaysRun = true)
public static void getEnvDetails() {

    BaseStepClass.env=System.getProperty("env");    

}

}

prashant-ramcharan commented 3 years ago

Can you see all the project libs (jar files) in the target/libs directory before running the tests?

You should try running the copy-dependencies maven goal first.

And do you get the same error when running this: https://github.com/prashant-ramcharan/courgette-jvm-classpath-example/tree/master/courgette-jvm-maven

kawalbhatia commented 3 years ago

Hi @prashant-ramcharan , Thanks for looking in to it . I checked both the things mentioned by you .

  1. I dont see target/libs folder being created for my project, but same is getting created when i execute Courgette-jvm-maven . Not sure what's wrong with the pom dependency i shared with you in pom.xml. If you have any clue, please suggest .
  2. I am seeing the same error when i run https://github.com/prashant-ramcharan/courgette-jvm-classpath-example/tree/master/courgette-jvm-maven

Created at 2021-02-01T19:02:37.659

Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream '@example'. java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command '@example'. at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.(ForkClient.java:511) at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:209) at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:176) at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88) at java.lang.Thread.run(Thread.java:748)

prashant-ramcharan commented 3 years ago

Can you try running the Courgette runner directly? Not using the maven-surefire-plugin ?

Also confirm the following:

kawalbhatia commented 3 years ago

Hi @prashant-ramcharan ,

I executed the https://github.com/prashant-ramcharan/courgette-jvm-classpath-example/tree/master/courgette-jvm-maven directly using runner file without maven-surefire plugin and it worked like a charm without any error.

Also find below other details as required :

Operating system : Windows 10 pro Maven version : Apache Maven 3.6.3 Java version : 1.8.0_251

prashant-ramcharan commented 3 years ago

That's great @kawalbhatia

I assume you running the maven tests from IntelliJ or Eclipse?

Can you try running mvn test from a separate command line program and not from IntelliJ or Eclipse?

kawalbhatia commented 3 years ago

Hi @prashant-ramcharan - Tried running mvn test from command line . Getting the same error while executing through mvn test .

prashant-ramcharan commented 3 years ago

Ok to go back to the original issue which is the CreateProcess error=206, can you verify this works fine in your main project when running the Courgette runner directly?

If not, please share a project I can use.

kawalbhatia commented 3 years ago

Hi @prashant-ramcharan , I hope you are referring to original issue i was getting with version 5.9.1 of Courgette library.

Please find attached the sample project , if we run using maven(mv test) on windows, it gives the java.io.IOException: Cannot run program "java": CreateProcess error=206, The filename or extension is too long.

We have two test runner file here :

  1. FeatureSuite.java ( This is with Courgette option) which is currently configured in com.cucumber.ksb.etom.test.testng\testng.xml to use and gives this error.
  2. KSBTestRunner.java - This is without Courgette option and if configure it in testng.xml to be used, it does not give any error.

Please let me know in case more details are required. ParallelExecution.zip

prashant-ramcharan commented 3 years ago

Thanks @kawalbhatia - will take a look.

prashant-ramcharan commented 3 years ago

@kawalbhatia I ran your project on a Windows machine and I don't get the Create Process 206 error.

I also had to update your Courgette runner and pom file to make it work. Your plugins were incorrect and had missing deps. The runner now uses a custom class path as mentioned in my earlier comment.

See updated project attached: UPDATED_ParallelExecution.zip

Here is the video: https://recordit.co/Rfk3VqU38o (Windows 10 + Maven + Java 8)

kawalbhatia commented 3 years ago

Hi @prashant-ramcharan - Thanks very much for looking in to it . Not sure why it was not working earlier .But now with the changes you shared, it is working fine. Thanks again . We can close this ticket.