[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.362s
[INFO] Finished at: Wed Mar 20 15:14:25 CET 2013
[INFO] Final Memory: 16M/221M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project spock-webdriver: ExecutionException; nested exception is java.util.concurrent.ExecutionException: java.lang.RuntimeException: There was an error in the forked process
[ERROR] java.lang.NoSuchMethodError: org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(Lorg/junit/runner/Result;)V
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:129)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:601)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
当在我的pom.xml中启用强制使用JUnit47提供程序时,我得到:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.271s
[INFO] Finished at: Wed Mar 20 15:31:42 CET 2013
[INFO] Final Memory: 17M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project spock-webdriver: ExecutionException; nested exception is java.util.concurrent.ExecutionException: java.lang.RuntimeException: There was an error in the forked process
[ERROR] java.lang.NoSuchMethodError: org.apache.maven.surefire.util.TestsToRun.size()I
[ERROR] at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:123)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:601)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
pom.xml如下所示
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.31.0</version>
<scope>compile</scope>
</dependency>
<!--If this is commented out parallel testing is not working!!! When in testexecution itself is not working -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-maven</artifactId>
<version>0.7-groovy-2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<configuration>
<providerSelection>1.7</providerSelection>
<source/>
</configuration>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.7</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.6</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<dependencies>
</dependencies>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<!-- Surefire 2.14+ configuration for parallelization -->
<forkCount>5</forkCount>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
这是一个老线程,但对于其他可能遇到此问题的人来说...此错误是由于与surefire插件依赖项和spock 0.7.0依赖项不一致造成的。Spock使用surefire-junit47版本2.11。这个类/方法Junit4RunListener.RethrowanyTestMechanismFailures不存在于该可靠版本中。解决方案是从spock依赖项定义中排除surefire版本,如下所示:
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-maven</artifactId>
<version>0.7-groovy-2.0</version>
<exclusions>
<exclusion> <!-- exclude so we can pick up surefire-junit4 2.17 version for failsafe integration tests -->
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
</exclusion>
</exclusions>
</dependency>
现在,它将使用您定义的surefire版本,为了完整起见,下面是我使用的surefire依赖:
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.17</version>
</dependency>
然后是surefire插件定义,它允许单元测试和集成测试分开启动(这一部分更多的是让单元测试、集成测试、spock、maven和groovy发挥良好作用)。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
<configuration>
<forkCount>0</forkCount>
<includes>
<include>%regex[.*Test.*]</include>
</includes>
<excludes>
<exclude>%regex[.*IntegrationTest.*]</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<configuration>
<includes>
<include>%regex[.*IntegrationTest.*]</include>
</includes>
</configuration>
<executions>
<execution>
<id>failsafe-integration-tests</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
我正在努力获得Cucumber-JVM V4.0.0与JUnit/Maven一起工作的新并行执行特性。 如前所述,如果在POM中相应地配置和,并使用依赖项注入来共享状态(我使用的是Pico Continer),那么Cucumber特性应该并行执行。 如果有用的话,下面是我的runner类(com.softwareAutomation.world是DI类) 请参阅下面从Maven运行时的失败堆栈跟踪
它是可以配置surefire插件只运行一些测试并行和其他顺序? 也可以使用surefireforkCount来运行声明为jUnit Suite的并行测试吗?
我们用Rest Assured和JUnit 5编写了API测试,并试图并行运行测试,因为测试之间没有依赖关系。我们已经尝试了JUnit 5的实验性并行执行,方法是设置: …但我们已经看到,通常当测试失败时,测试报告中不包含它们的输出。 这是已知问题吗?有什么变通方法吗?
以下是我的POM的相关部分: 编辑:当我在方法中添加关闭挂钩时,问题就解决了。当我将它添加到方法中时,我遇到了问题。我希望能够在任何时候添加钩子。
问题内容: 我正在使用JUnit 4.4和Maven,并且有大量的长时间运行的集成测试。 关于并行化测试套件,有一些解决方案可以让我在单个测试类中并行运行每个测试方法。但是所有这些都要求我以一种或另一种方式更改测试。 我真的认为,在X线程中并行运行X个不同的测试类将是一种更干净的解决方案。我有成百上千的测试,所以我真的不在乎线程测试类。 问题答案: 使用Maven插件:
Jenkins不熟悉,所以我有一个java web项目(maven)和一个单元测试文件。测试文件结构:src/test/Java/preprocessortest . Java 该测试在intellij中成功执行。但是Jenkins并不认为这个测试文件是成功的。 它显示“没有要运行的测试” Jenkins控制台日志 pom.xml (编辑)当我使用cmd作为“mvn test”在pc中进行mave