@RepeatedTest example

This lesson demonstrates how to use @RepeatedTest annotation to run tests multiple times.

We'll cover the following

@Repeated Tests

JUnit 5 Jupiter provides the ability to repeat a test a specified number of times. It is done by simply annotating a method with @RepeatedTest. To this annotation, we specify a number which is the total number of repetitions desired. For each and every invocation of a repeated test, it behaves like the execution of a regular @Test method. Also, each test is executed with support for the same lifecycle callbacks and extensions. Instead of using @Test annotation, we use @RepeatedTest annotation.

Let’s take a look at a demo.

Get hands-on with 1200+ tech skills courses.