如何解决Maven 故障安全插件在并行运行时忽略线程数
我有这个 maven-failsafe-plugin
执行配置:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<executions>
<!-- ... other executions -->
<execution>
<id>multi-threaded-test-run</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skipITs>${skipParallel}</skipITs>
<excludes>
<exclude>**/AA_*.java</exclude>
<exclude>**/ZZ_*.java</exclude>
</excludes>
<excludedGroups>com.snc.mobile.sg.core.attributes.SGNotthreadSafe</excludedGroups>
<parallel>classesAndMethods</parallel>
<threadCount>20</threadCount>
<argLine>-XshowSettings:vm -xms128m -Xmx3072m -XX:MaxMetaspaceSize=1024m</argLine>
</configuration>
</execution>
<!-- ... other executions -->
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.17</version>
<scope>compile</scope>
</dependency>
</dependencies>
<plugin>
在实际运行测试时,Maven(或者它是 Junit?)似乎完全忽略了我给它的任何线程数,并行运行所有测试。
我还尝试了其他配置,包括将 parallel
设置为仅 methods
,以及设置更具体的线程计数 (threadCountClasses/threadCountMethods)。
我在这里做错了什么?
附言假设 skipParallel
始终为 false,这不是问题,执行确实会运行。
谢谢,阿维。
解决方法
显然,我错过了<perCoreThreadCount>false</perCoreThreadCount>
。
默认情况下它是 true,它会覆盖您提供的线程号,尽管它在文档中被称为“可选”。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。