Возможно ли выполнить тестовый пример параллельно с JUnit 5?
Я ищу что-то вроде threadPoolSize и invocationCount из TestNG :
threadPoolSize
invocationCount
@Test(threadPoolSize = 3, invocationCount = 10, timeOut = 10000)
Вы можете написать параллельные тесты с JUnit 5.3.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
junit.jupiter.execution.parallel.enabled=true
https://junit.org/junit5/docs/current/user-guide/#running-tests-config-params
Добавьте это в свою конфигурацию JUnit, если вам нужен fixed thread pool:
fixed thread pool
junit.jupiter.execution.parallel.config.strategy=fixed junit.jupiter.execution.parallel.config.fixed.parallelism=4
Для продолжения - теперь это доступно в качестве экспериментальной функции JUnit 5.3: https://junit.org/junit5/docs/snapshot/user-guide/index.html#writing-tests-parallel-execution