3

Given the following Junit5 test class, how do I run upperCaseTest and lowerCaseTest in parallel while the parameterized runs within each test method run in sequence. In other words, "A", "B" and "C" should run in sequence, "x", "y", "z" should run in sequence but "A" and "x" should be able to run in parallel.

@Execution(ExecutionMode.CONCURRENT)
class ParallelParameterizedTest {

    @ParameterizedTest
    @ValueSource(strings = {"A", "B", "C"})
    void upperCaseTest(String s) {
        assertEquals(s.toUpperCase(), s);
    }

    @ParameterizedTest()
    @ValueSource(strings = {"x", "y", "z"})
    void lowerCaseTest(String s) {
        assertEquals(s.toLowerCase(), s);
    }
}

My junit-platform.properties file is as follows:

junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.config.strategy = fixed
junit.jupiter.execution.parallel.config.fixed.parallelism = 2

The actual behaviour is that all tests run in parallel.

There is an ongoing thread on Junit5's Gitter page (https://gitter.im/junit-team/junit5?at=6005fe8fac653a0802c8c258)

0 Answers0