Add repeated module: @RepeatedTest from JUnit 5 to JUnit 6 (6.1.3, JDK 25)

This commit is contained in:
Claude
2026-10-08 15:53:40 +00:00
parent fd3434c42d
commit 84721c3e58
16 changed files with 657 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
# mvn test -- full committed suite (ReliabilityTest, CustomNameTest, LifecycleTest, MetadataTest)
[INFO] -------------------------------------------------------
[INFO] Running com.ankurm.tutorials.junit.repeated.ReliabilityTest
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.275 s -- in com.ankurm.tutorials.junit.repeated.ReliabilityTest
[INFO] Running com.ankurm.tutorials.junit.repeated.CustomNameTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.063 s -- in com.ankurm.tutorials.junit.repeated.CustomNameTest
[INFO] Running com.ankurm.tutorials.junit.repeated.LifecycleTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.034 s -- in com.ankurm.tutorials.junit.repeated.LifecycleTest
[INFO] Running com.ankurm.tutorials.junit.repeated.MetadataTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 s -- in com.ankurm.tutorials.junit.repeated.MetadataTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 14, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.788 s
[INFO] Finished at: 2026-10-08T21:23:02+05:30
[INFO] ------------------------------------------------------------------------
@@ -0,0 +1,7 @@
== TestInfo.getDisplayName() for each repetition ==
repetition 1 of 5
repetition 2 of 5
repetition 3 of 5
repetition 4 of 5
repetition 5 of 5
@@ -0,0 +1,5 @@
== TestInfo.getDisplayName() with a custom name() pattern ==
Critical API Integration - Run 1/3
Critical API Integration - Run 2/3
Critical API Integration - Run 3/3
@@ -0,0 +1,27 @@
# Scratch run: {shortDisplayname} is not a real placeholder (ScratchPlaceholderTest, removed before commit)
Thanks for using JUnit! Support its development at https://junit.org/sponsoring
╷
├─ JUnit Platform Suite ✔
├─ JUnit Jupiter ✔
│ └─ ScratchPlaceholderTest ✔
│ └─ bogusPlaceholderTest() ✔
│ ├─ {shortDisplayname} test ✔
│ └─ {shortDisplayname} test ✔
└─ JUnit Vintage ✔
Test run finished after 204 ms
[ 5 containers found ]
[ 0 containers skipped ]
[ 5 containers started ]
[ 0 containers aborted ]
[ 5 containers successful ]
[ 0 containers failed ]
[ 2 tests found ]
[ 0 tests skipped ]
[ 2 tests started ]
[ 0 tests aborted ]
[ 2 tests successful ]
[ 0 tests failed ]
@@ -0,0 +1,5 @@
== RepetitionInfo across all 3 repetitions ==
repetition 1 of 3 -- getFailureCount()=0 getFailureThreshold()=2
repetition 2 of 3 -- getFailureCount()=0 getFailureThreshold()=2
repetition 3 of 3 -- getFailureCount()=0 getFailureThreshold()=2
@@ -0,0 +1,15 @@
== Call order across 3 repetitions ==
@BeforeAll
@BeforeEach (repetition 1)
@RepeatedTest (repetition 1)
@AfterEach (repetition 1)
@BeforeEach (repetition 2)
@RepeatedTest (repetition 2)
@AfterEach (repetition 2)
@BeforeEach (repetition 3)
@RepeatedTest (repetition 3)
@AfterEach (repetition 3)
@AfterAll
Totals -- @BeforeAll: 1, @AfterAll: 1, @BeforeEach: 3, @AfterEach: 3
@@ -0,0 +1,47 @@
# Scratch run: @RepeatedTest with no failureThreshold -- all 10 repetitions still run even though 2 fail (FlakyDetectionDemoTest, removed before commit)
Thanks for using JUnit! Support its development at https://junit.org/sponsoring
╷
├─ JUnit Platform Suite ✔
├─ JUnit Jupiter ✔
│ └─ FlakyDetectionDemoTest ✔
│ └─ intermittentRaceCondition(RepetitionInfo) ✔
│ ├─ repetition 1 of 10 ✔
│ ├─ repetition 2 of 10 ✔
│ ├─ repetition 3 of 10 ✔
│ ├─ repetition 4 of 10 ✘ simulated race condition reproduced on repetition 4
│ ├─ repetition 5 of 10 ✔
│ ├─ repetition 6 of 10 ✔
│ ├─ repetition 7 of 10 ✔
│ ├─ repetition 8 of 10 ✘ simulated race condition reproduced on repetition 8
│ ├─ repetition 9 of 10 ✔
│ └─ repetition 10 of 10 ✔
└─ JUnit Vintage ✔
Failures (2):
JUnit Jupiter:FlakyDetectionDemoTest:intermittentRaceCondition(RepetitionInfo):repetition 4 of 10
MethodSource [className = 'com.ankurm.tutorials.junit.repeated.FlakyDetectionDemoTest', methodName = 'intermittentRaceCondition', methodParameterTypes = 'org.junit.jupiter.api.RepetitionInfo']
=> org.opentest4j.AssertionFailedError: simulated race condition reproduced on repetition 4
org.junit.jupiter.api.Assertions.fail(Assertions.java:142)
com.ankurm.tutorials.junit.repeated.FlakyDetectionDemoTest.intermittentRaceCondition(FlakyDetectionDemoTest.java:14)
JUnit Jupiter:FlakyDetectionDemoTest:intermittentRaceCondition(RepetitionInfo):repetition 8 of 10
MethodSource [className = 'com.ankurm.tutorials.junit.repeated.FlakyDetectionDemoTest', methodName = 'intermittentRaceCondition', methodParameterTypes = 'org.junit.jupiter.api.RepetitionInfo']
=> org.opentest4j.AssertionFailedError: simulated race condition reproduced on repetition 8
org.junit.jupiter.api.Assertions.fail(Assertions.java:142)
com.ankurm.tutorials.junit.repeated.FlakyDetectionDemoTest.intermittentRaceCondition(FlakyDetectionDemoTest.java:14)
Test run finished after 281 ms
[ 5 containers found ]
[ 0 containers skipped ]
[ 5 containers started ]
[ 0 containers aborted ]
[ 5 containers successful ]
[ 0 containers failed ]
[ 10 tests found ]
[ 0 tests skipped ]
[ 10 tests started ]
[ 0 tests aborted ]
[ 8 tests successful ]
[ 2 tests failed ]
@@ -0,0 +1,47 @@
# Scratch run: @RepeatedTest(failureThreshold = 2) -- after the 2nd failure (repetition 8), repetitions 9 and 10 are SKIPPED, not invoked (FailureThresholdStopsRemainingDemoTest, removed before commit)
Thanks for using JUnit! Support its development at https://junit.org/sponsoring
╷
├─ JUnit Platform Suite ✔
├─ JUnit Jupiter ✔
│ └─ FailureThresholdStopsRemainingDemoTest ✔
│ └─ intermittentRaceCondition(RepetitionInfo) ✔
│ ├─ repetition 1 of 10 ✔
│ ├─ repetition 2 of 10 ✔
│ ├─ repetition 3 of 10 ✔
│ ├─ repetition 4 of 10 ✘ simulated race condition reproduced on repetition 4
│ ├─ repetition 5 of 10 ✔
│ ├─ repetition 6 of 10 ✔
│ ├─ repetition 7 of 10 ✔
│ ├─ repetition 8 of 10 ✘ simulated race condition reproduced on repetition 8
│ ├─ repetition 9 of 10 ↷ Failure threshold [2] exceeded
│ └─ repetition 10 of 10 ↷ Failure threshold [2] exceeded
└─ JUnit Vintage ✔
Failures (2):
JUnit Jupiter:FailureThresholdStopsRemainingDemoTest:intermittentRaceCondition(RepetitionInfo):repetition 4 of 10
MethodSource [className = 'com.ankurm.tutorials.junit.repeated.FailureThresholdStopsRemainingDemoTest', methodName = 'intermittentRaceCondition', methodParameterTypes = 'org.junit.jupiter.api.RepetitionInfo']
=> org.opentest4j.AssertionFailedError: simulated race condition reproduced on repetition 4
org.junit.jupiter.api.Assertions.fail(Assertions.java:142)
com.ankurm.tutorials.junit.repeated.FailureThresholdStopsRemainingDemoTest.intermittentRaceCondition(FailureThresholdStopsRemainingDemoTest.java:14)
JUnit Jupiter:FailureThresholdStopsRemainingDemoTest:intermittentRaceCondition(RepetitionInfo):repetition 8 of 10
MethodSource [className = 'com.ankurm.tutorials.junit.repeated.FailureThresholdStopsRemainingDemoTest', methodName = 'intermittentRaceCondition', methodParameterTypes = 'org.junit.jupiter.api.RepetitionInfo']
=> org.opentest4j.AssertionFailedError: simulated race condition reproduced on repetition 8
org.junit.jupiter.api.Assertions.fail(Assertions.java:142)
com.ankurm.tutorials.junit.repeated.FailureThresholdStopsRemainingDemoTest.intermittentRaceCondition(FailureThresholdStopsRemainingDemoTest.java:14)
Test run finished after 292 ms
[ 5 containers found ]
[ 0 containers skipped ]
[ 5 containers started ]
[ 0 containers aborted ]
[ 5 containers successful ]
[ 0 containers failed ]
[ 10 tests found ]
[ 2 tests skipped ]
[ 8 tests started ]
[ 0 tests aborted ]
[ 6 tests successful ]
[ 2 tests failed ]