使用 Maven Surefire,我无法分叉并行测试执行。也就是说,我的每个测试用例都必须在单独的 JVM 中运行,因此需要分叉。此外,我希望我的测试用例并行运行。第一部分工作没有问题:我能够在自己的 JVM 中运行每个测试用例。然而,第二部分对我来说仍然是一个挑战。我还没有成功地让测试用例并行执行。这是我的插件声明的样子:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<parallel>methods</parallel>
<forkMode>always</forkMode>
<argLine>-Xms512m -Xmx512m</argLine>
</configuration>
</plugin>
我已经尝试了方法和类,但没有看到任何并行化。
我的 JUnit 版本是 4.7,如依赖声明所示:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>compile</scope>
</dependency>
任何帮助将非常感激。
格雷瓜尔.
我认为你应该使用threadCount http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#threadCount使用时的参数parallel http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#parallel mode:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<forkMode>always</forkMode>
<argLine>-Xms512m -Xmx512m</argLine>
<parallel>methods</parallel>
<threadCount>4</threadCount>
</configuration>
</plugin>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)