Copilot commented on code in PR #3652:
URL: https://github.com/apache/maven-surefire/pull/3652#discussion_r4731282670
##########
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:
For a `@ParameterizedClass` (including its nested classes), one invocation
can pass while another always fails `@BeforeAll`, yet both have the same
qualified/report class names. This helper accepts the passing invocation as
recovery, turning the persistent error into a flake in both XML and global
statistics and potentially allowing the build to pass. Preserve
container/invocation identity through reporting and require recovery on a later
attempt of the failed scope; add a regression covering mixed passing and
failing invocations.
--
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]