[SOLVED] JUnit @RepeatedTest for concurrent execution


I’ve read following article and I understand that I can ask junit to execute test several times by adding following annotation:

@RepeatedTest(value = 3, name = RepeatedTest.LONG_DISPLAY_NAME)

But I want to start these 3 time in parallel.
Is it posssible?

P.S. I want to check that tests pass correctly for 10+ threads


Nowadays this is possible by leveraging the (experimental) Parallel Execution feature. For this you need to add a junit-platform.properties file to your test resource directory. You also need to add the @Execution(ExecutionMode.CONCURRENT) to your tests. See the examples below:


junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent


import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

class ParallelRepeatTest {

    void testVilocDecodingWithSabotagedFalse_usingMqttPlug() throws Exception {

If you need to tweak the threading settings, refer to the junit5 documentation linked above.

Answered By – Seanvd

Answer Checked By – Robin (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *