JUnit Jupiter provides for the ability to repeat a test a specified number of times simply by annotating a method with @RepeatedTest, specifying the total number of repetitions desired. Each repeated test behaves exactly as a regular @Test method. Moreover, each repeated test preserves the same lifecycle callbacks (@BeforeEach, @AfterEach, and so on).
The following Java class contains a test that is going to be repeated five times:
package io.github.bonigarcia;
import org.junit.jupiter.api.RepeatedTest;
class SimpleRepeatedTest {
@RepeatedTest(5)
void test() {
System.out.println("Repeated test");
}
}
Due to the fact that this test only writes a line (Repeated test) in the standard output, when executing this test in the console, we will see that trace five times:
Execution of repeated test in the console
In addition to specifying the number...