首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在每个测试类都有自己的并行JVM的情况下,如何运行Maven surefire?

在每个测试类都有自己的并行JVM的情况下,如何运行Maven surefire?
EN

Stack Overflow用户
提问于 2015-02-28 16:58:26
回答 1查看 10.1K关注 0票数 4

无论我为Maven +尽力而为使用了什么设置,在我的流程管理器中,我从未见过超过一个JVM。我有一台Windows 7电脑,有8个物理内核。我正在运行最新的Maven / Surefire / JUnit和JDK8 (32位)。

我试着把所有的测试分解成每个测试类的一个测试。(我读到JVM只产生于测试类,而不是测试方法。)不过,我在流程管理器中从未见过超过一个JVM。

理想情况下,我希望每个测试类并行运行单独的JVM -- 8(每个内核一个/不要反悔JVM)。

所需的Maven安全设置是什么?

以下几点对我不适用:

代码语言:javascript
复制
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
            <configuration>
                <includes>
                    <include>${default.test.suite}</include>
                </includes>
                <reuseForks>false</reuseForks>
                <forkCount>1.0C</forkCount>
                <parallel>classes</parallel>
                <threadCount>1</threadCount>
<!--
                <useUnlimitedThreads>true</useUnlimitedThreads>
                <parallelOptimized>false</parallelOptimized>
-->
            </configuration>
        </plugin>

(我尝试了reuseForksforkCountparallelthreadCountuseUnlimitedThreadsparallelOptimized的各种组合。)

EN

回答 1

Stack Overflow用户

发布于 2015-03-06 18:56:56

如果您使用的是JUnit,那么首先“并行”只适用于TestNG,其他一些属性也是如此,因此它们对您没有帮助/兴趣:

  • http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html

下面是在JUnit设置中对我们有用的内容(对于TestNG不太管用,就像刚刚在这里发布的:Running test in parallel with surefire and displaying them properly with the TestNG Jenkins plugin):

代码语言:javascript
复制
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <reuseForks>false</reuseForks>
    <forkCount>2.5C</forkCount>
  </configuration>
</plugin>

因此,我认为您需要增加您的forkCount (使用forkCount = 1.0,您不会得到并行的东西)。

作为参考,这里有一些关于并行运行测试时的小打印的更多信息(包括。forkCount解释和示例):

  • http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28784366

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档