The @RepeatedTest annotation enable to run multiple times single tests in JUnit 5. The number of times the test will be executed can be configured as parameter to @RepeatedTest annotation.

Example:

@Test
@RepeatedTest(5)
void addNumber() {
    Calculator calculator = new Calculator();
Random rand = new Random();
int n = rand.nextInt(50);

    Assertions.assertEquals(n*2, calculator.add(n, n), "Checking calculator sum");
}

In above code, addNumber() test will executed 5 times. Also note that each invocation of a repeated test works just like the execution of a regular @Test method. I.e. you have full support for the same lifecycle callbacks and extensions.

FREE WildFly Application Server - JBoss - Quarkus - Drools Tutorials