【发布时间】:2018-07-12 14:24:00
【问题描述】:
以前我使用 Maven+Selenide+JUnit4 进行测试,这很好,并行运行效果很好。示例:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin}</version>
<configuration>
<parallel>all</parallel>
<perCoreThreadCount>true</perCoreThreadCount>
<threadCount>4</threadCount>
<perCoreThreadCount>false</perCoreThreadCount>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
在 Jenkins 工作中,我能够运行测试(示例如下)
mvn -Dtest=TestClassName test
我的测试在 4 个浏览器中运行。
在我切换到JUnit5之前,因为我想通过标签使用运行测试,例如
@Test
@Tag("smoke")
public void test1() {}
并运行下一条命令标记为“冒烟”的所有测试:
mvn -Dtag=smoke test
但我遇到了下一个问题:并行执行不起作用,我仍然没有找到解决方案。 我发现了这个错误https://github.com/junit-team/junit5/issues/1424
如何与 JUnit5 并行运行测试?
我尝试在pom.xml
中使用<forkCount>2</forkCount>
<reuseForks>true</reuseForks>
<parallel>all</parallel>
它没有帮助,我创建了一个文件 junit-platform.properties 并插入那里
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.config.strategy = fixed
但无论如何我都无法解决这个问题。
【问题讨论】:
-
您使用的是不同 JUnit JAR 的哪些版本?
-
嗨!我使用
5.2.0 -
我的 pom.xml github.com/13Dima13/G/blob/master/pom.xml 我已经切换到最新的 5.3.0-M1 版本了,但是无论如何我都没有知道如何并行运行。
-
您是否阅读了用户指南中的说明? junit.org/junit5/docs/snapshot/user-guide/…
-
我当然读过。你检查过我之前描述的吗?我不能并行运行
标签: maven parallel-processing junit5 selenide