Running test in parallel with surefire and displaying them properly with the TestNG Jenkins plugin

早过忘川 提交于 2019-12-02 05:04:41

I actually ended up finding a solution that worked for me.

I think the problem is trying to do it with forkCount / reuseForks, so I've set those back to the default (you could also just skip those properties if you're not trying to overwrite something from a base pom etc.).

Instead I've used parallel and threadCount. Those however only apply to TestNG, but then, I also need it for TestNG (not JUnit).

This makes tests run in parallel, but the testng-results.xml is generated correctly (without being overwritten by each test running in parallel).

More details here:

Here's the plugin configuration I have now:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <!-- those are the two default values, you can probably skip them -->
    <forkCount>1</forkCount>
    <reuseForks>true</reuseForks>
    <!-- that's what made it work -->
    <parallel>classes</parallel>
    <threadCount>10</threadCount>
  </configuration>
</plugin>

Obviously, the thread count could be lower or higher depending on what you want to do / what specs your server has, and you could change the settings depending on whether you want to run classes, or some other "level" in parallel.

Also, you could configure parallel and threadCount together with any other properties in the suite file, if you choose to use a suite file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!