Skip to content

Commit

Permalink
Retry class-level lifecycle flakiness for JUnit5 (issue #24)
Browse files Browse the repository at this point in the history
* Fixes retrying for Gradle 5.0 only, which uses the method name "classMethod" rather than "initializationError"
  • Loading branch information
Jon Schneider committed Jan 30, 2020
1 parent 2635992 commit 0d525bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ TestFramework createRetryingTestFramework(JvmTestExecutionSpec spec, Test testTa
failedTests.stream()
.filter(failedTest -> failedTest.getClassName() != null)
.forEach(failedTest -> {
if ("executionError".equals(failedTest.getName()) || "initializationError".equals(failedTest.getName())) {
if ("classMethod".equals(failedTest.getName()) || "executionError".equals(failedTest.getName()) ||
"initializationError".equals(failedTest.getName())) {
// failures in JUnit5 lifecycle methods yield a failure on methods of these names
retriedTestFilter.includeTestsMatching(failedTest.getClassName());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public void started(TestDescriptorInternal descriptor, TestStartEvent testStartE

// remove JUnit5 @BeforeAll/@AfterAll failures.
nonExecutedFailedTests.remove(new TestName(descriptor.getClassName(), "initializationError"));

// ONLY for Gradle 5.0, the lifecycle method name is "classMethod"
// remove JUnit5 @BeforeAll/@AfterAll failures.
nonExecutedFailedTests.remove(new TestName(descriptor.getClassName(), "classMethod"));
} else if(testFramework instanceof TestNGTestFramework) {
// remove TestNG lifecycle method failures.
nonExecutedFailedTests.remove(new TestName(descriptor.getClassName(), "lifecycle"));
Expand Down

0 comments on commit 0d525bf

Please sign in to comment.