olamy commented on code in PR #3652:
URL: https://github.com/apache/maven-surefire/pull/3652#discussion_r4731299512
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java:
##########
@@ -433,6 +442,28 @@ boolean printTestFailures(TestResultType type) {
return printed;
}
+ /**
+ * Whether a passing test shows that a class whose {@code @BeforeAll}
failed got through it on a rerun.
+ *
+ * @param failedClass qualified name of the class whose {@code @BeforeAll}
failed, {@code null} if unknown
+ * @param failedReportClass class name the failure is reported under
+ * @param passedClass qualified name of the class of the passing test,
{@code null} if unknown
+ * @param passedReportClass class name the passing test is reported under
+ */
+ static boolean passedAfterBeforeAllFailure(
+ String failedClass, String failedReportClass, String passedClass,
String passedReportClass) {
+ if (failedReportClass == null ||
!failedReportClass.equals(passedReportClass)) {
+ return false;
+ }
+ // A top-level class, or no qualified name: any test reported under
the same class counts
+ if (failedClass == null || passedClass == null ||
failedClass.equals(failedReportClass)) {
+ return true;
+ }
+ // A nested class is reported under its outer class. Only its own
tests, or the tests of
+ // classes nested in it, show that its @BeforeAll passed. A passing
outer test doesn't.
+ return passedClass.equals(failedClass) ||
passedClass.startsWith(failedClass + '$');
Review Comment:
Good catch, but it isn't new with this PR. On master a passing test anywhere
in a top-level class already counts as recovery for that class's `@BeforeAll`
failure, so a `@ParameterizedClass` with one passing and one always-failing
invocation is already a flake there.
Fixing it means carrying the container/invocation identity through the
report entries, which the reporting doesn't have today. That's its own change,
so I'll do it in a follow-up rather than grow this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]