Skip to content

Commit

Permalink
Ignore un-retried methods if class-level failure occurred
Browse files Browse the repository at this point in the history
Signed-off-by: Pavlo Shevchenko <pshevchenko@gradle.com>
  • Loading branch information
pshevche committed Feb 23, 2023
1 parent 4fd0a03 commit 7ea416d
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,21 @@ public void completed(Object testId, TestCompleteEvent testCompleteEvent) {
addRetry(className, name);
}

// class-level lifecycle failures do not guarantee that all methods that failed in the previous round will be re-executed (e.g. due to class setup failure)
// in this case, we retry the entire class, so we ignore method-level failures for the next round
// we keep all lifecycle failures from previous round to make sure we report them as passed later on
if (isLifecycleFailure(className, name)) {
previousRoundFailedTests.remove(className, n -> {
if (isLifecycleFailure(className, n)) {
addRetry(className, n);
}
return true;
});
}

if (isClassDescriptor(descriptor)) {
previousRoundFailedTests.remove(className, n -> {
if (testFrameworkStrategy.isLifecycleFailureTest(testsReader, className, n)) {
if (isLifecycleFailure(className, n)) {
emitFakePassedEvent(descriptor, testCompleteEvent, n);
return true;
} else {
Expand All @@ -114,6 +126,10 @@ public void completed(Object testId, TestCompleteEvent testCompleteEvent) {
delegate.completed(testId, testCompleteEvent);
}

private boolean isLifecycleFailure(String className, String name) {
return testFrameworkStrategy.isLifecycleFailureTest(testsReader, className, name);
}

private void addRetry(String className, String name) {
if (classRetryMatcher.retryWholeClass(className)) {
currentRoundFailedTests.addClass(className);
Expand Down

0 comments on commit 7ea416d

Please sign in to comment.