how to fix the maven surefire plugin error [there was error in the forked process]?
23,931
I faced the same issue but it got resolved with different solution, you can check below problems as well.
Actually i have given the wrong testNG.xml path in POM.XML that's why it was throwing me that error. Please cross verify your testNG.xml path.
Author by
user1553680
Updated on July 09, 2022Comments
-
user1553680 almost 2 years
I am trying to run my sample project which uses Maven- testNG-cucumber and deploy it using docker . here is my Dockerfile
FROM maven:3.6.0-jdk-8 RUN mkdir /docker WORKDIR /docker COPY pom.xml . COPY testng.xml . COPY src . RUN mvn clean verify
POM.XML
<dependencies> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.2.5</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-jvm-deps</artifactId> <version>1.0.5</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-testng</artifactId> <version>1.2.5</version> <scope>compile</scope> <exclusions> <exclusion> <groupId>junit</groupId> <artifactId>junit</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.8</version> <scope>test</scope> </dependency> <dependency> <groupId>net.masterthought</groupId> <artifactId>cucumber-reporting</artifactId> <version>3.8.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.44.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.4</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.20.1</version> <configuration> <suiteXmlFiles> <suiteXmlFile>testng.xml</suiteXmlFile> </suiteXmlFiles> <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin> <plugin> <groupId>net.masterthought</groupId> <artifactId>maven-cucumber-reporting</artifactId> <version>3.8.0</version> <executions> <execution> <id>execution</id> <phase>verify</phase> <goals> <goal>generate</goal> </goals> <configuration> <projectName>Sample</projectName> <outputDirectory>target/cucumber-reports/advanced-reports</outputDirectory> <cucumberOutput>target/cucumber-reports/CucumberTestReport.json</cucumberOutput> <buildNumber>1</buildNumber> <parallelTesting>false</parallelTesting> </configuration> </execution> </executions> </plugin> </plugins> </build>
above scenario works completely fine when i run the project locally using mvn verify .Then i try to build the image using docker build -t sample . . this time i have got the following error .
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project Sample: There are test failures. [ERROR] Please refer to /docker/target/surefire-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream. [ERROR] There was an error in the forked process [ERROR] Cannot find class in classpath: TestRunner [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process [ERROR] Cannot find class in classpath: TestRunner [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork (ForkStarter.java:673) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork (ForkStarter.java:535) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run (ForkStarter.java:280) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run (ForkStarter.java:245) [ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider (AbstractSurefireMojo.java:1124) [ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo. executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
Any help would be much appreciated
-
Admin over 2 yearsYour answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.