I have a parameterized junit integration-test. It has 30 inputs (giving it 30 tests to run) and each takes 18 sec.
I would like to run them in parallel.
I'm running them from gradle and they are currently written in jUnit4, but i'm ready to switch to jUnit5 if that helps.
At the moment I can use gradles maxParallelForks
but that only forks on classes.
The feature is available since v 5.3
Create src/test/resources/junit-platform.properties with the following content:
junit.jupiter.execution.parallel.enabled = true
To actually run tests in parallel, you need to annotate the test with
@Execution(ExecutionMode.CONCURRENT)
Alternatively, you can set this as the default for all tests in junit-platform.properties:
# run test methods in parallel by default
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.default
will run test methods in the same class (including parameterized methods) in parallel.
There is also a junit.jupiter.execution.parallel.mode.classes.default
to run tests from multiple classes in parallel. Check the picture in jUnit 5 docs to see the difference between 2 properties.