使用 Maven + Surefire 组合,我不能同时执行两个以上的线程。我已经尝试了许多 threadCount、perCoreThreadCount 和 useUnlimitedThreads 设置的组合,但永远不会比两个线程做得更好。见附上的截图:将有大约 12 个 Firefox 窗口,但一次只有两个“驱动”。
我的机器有 4 个 2.6 Ghz i7 内核,所以我还没有达到硬件限制。
以下是其中一种 Surefire 配置的示例:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<includes>
<include>**/*Test*.*</include>
</includes>
<threadCount>10</threadCount>
<perCoreThreadCount>true</perCoreThreadCount>
<parallel>classes</parallel>
</configuration>
</plugin>
对于我的测试,我使用的是包装在 JUnit 运行器中的 Scala。每个测试都在自己的类中。我认为我的 JUnit 是 4.10,Maven 3.04。