是否可以与 JUnit 5 并行执行测试用例?
我正在寻找类似的东西threadPoolSize
and invocationCount
from TestNG http://testng.org/doc/documentation-main.html#parallel-tests:
@Test(threadPoolSize = 3, invocationCount = 10, timeOut = 10000)
您可以使用 JUnit 5.3 编写并行测试。https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution
@Execution(ExecutionMode.CONCURRENT)
class MyTest {
@Test
void test1() throws InterruptedException {
Thread.sleep(1000);
System.out.println("Test1 " + Thread.currentThread().getName());
}
@Test
void test2() throws InterruptedException {
Thread.sleep(1000);
System.out.println("Test 2! " + Thread.currentThread().getName());
}
}
// should run simultaneously
记得添加junit.jupiter.execution.parallel.enabled=true
到你的 JUnit 配置
https://junit.org/junit5/docs/current/user-guide/#running-tests-config-params https://junit.org/junit5/docs/current/user-guide/#running-tests-config-params
如果您需要,请将其添加到您的 JUnit 配置中fixed thread pool
:
junit.jupiter.execution.parallel.config.strategy=fixed
junit.jupiter.execution.parallel.config.fixed.parallelism=4
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)