从Maven cmdline将threadCount传递到surefire插件

时间:2018-11-22 21:58:19

标签: maven junit cucumber

我在pom中为maven surefire插件设置了以下设置。 有时我可能想用更少的线程来运行测试。我希望从mvn命令行中进行设置。

<plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <version>2.22.0</version>
         <dependencies>
                <dependency>
                     <groupId>org.apache.maven.surefire</groupId>
                     <artifactId>surefire-junit47</artifactId>
                     <version>2.22.0</version>
                </dependency>
         </dependencies>
         <configuration>
                <parallel>methods</parallel>
                <threadCount>5</threadCount>
                <includes>
                         <include>com.Online.runner.Regression.ONLINE_Chrome_RunnerTest</include>
                </includes>
         </configuration>
</plugin> 

当我尝试使用下面的命令时,它似乎不起作用。

mvn clean test -X -DthreadCount=1

通过调试器检查值表明已设置系统属性。但是它似乎被忽略了。

[DEBUG] Setting system property [threadCount]=[1]
[DEBUG] parallel='methods', perCoreThreadCount=true, threadCount=5,

我的测试仍然并行运行。我究竟做错了什么?必须有一种方法可以在Pom中覆盖此值?

编辑:似乎它甚至完全忽略了threadCount值,即使是POM中的那个值也是如此。这个值不会传递给依赖项Junit47吗?

1 个答案:

答案 0 :(得分:0)

要使其正常运行,请使用pom.xml将其删除:

BasicClass copyWith({ String id, }) { // some code behaving differently for 1) id is undefined and 2) id is explicit null }

Maven启动行:

<threadCount> 5 </threadCount>