# JUnit 5 @RepeatedTest Demonstration This project demonstrates the usage of JUnit 5's `@RepeatedTest` annotation to improve test reliability and handle flaky tests. ## Concepts Covered The code examples in `src/test/java/com/ankurTutorials/junit/repeated` cover the following concepts: 1. **Basic Repetition**: Repeating a test a specific number of times. - File: `ReliabilityTest.java` 2. **Custom Display Names**: Configuring formatted names for each repetition for better reporting in CI/CD. - File: `CustomNameTest.java` 3. **Metadata Injection**: Using `RepetitionInfo` to access the current repetition index and total count within the test. - File: `MetadataTest.java` 4. **Lifecycle Management**: Understanding how `@BeforeEach` and `@AfterEach` interact with repeated tests (they run for *each* repetition). - File: `LifecycleTest.java` 5. **Failure Thresholds**: Using the `failureThreshold` attribute (JUnit 5.10+) to stop execution early if a certain number of failures occur. - File: `FlakyServiceTest.java` ## Prerequisites - Java 17 or higher - Maven 3.6+ ## How to Run To run all tests, execute the following command in the project root: ```bash mvn test ``` To run a specific test class: ```bash mvn -Dtest=BasicUsageTest test ```