Repeated Tests

Learn how to use the @RepeatedTest annotation in JUnit 5.

Using repeated tests

We may occasionally want to run a test method multiple times. JUnit 5 has the org.junit.jupiter.api.RepeatedTest annotation to easily support this requirement. We simply need to use @RepeatedTest instead of @Test to annotate methods and specify the total number of repetitions. Each repetition of the repeated test behaves like a regular test method with @Test.

Get hands-on with 1200+ tech skills courses.