olamy commented on code in PR #3652:
URL: https://github.com/apache/maven-surefire/pull/3652#discussion_r4747893510
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java:
##########
@@ -433,6 +449,37 @@ 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 || 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, nor does
+ // a test with no class, like a dynamic test with a classpath: source.
+ return passedClass != null && (passedClass.equals(failedClass) ||
passedClass.startsWith(failedClass + '$'));
Review Comment:
Good catch, fixed in b2858bc28. When a test has no source class of its own,
like a dynamic test with a `classpath:` source, the provider now gives it the
nested class it runs in, taken from its nearest class ancestor. Its pass then
counts as recovery for that nested class's `@BeforeAll`. Source-less tests from
other classes still don't count. Tests under a top-level class, and Cucumber
scenarios inside a `@Suite`, still get no qualified name, so their XML
`classname` stays the same.
`testWithNoClassOfItsOwnInsideANestedClassNamesThatClass` covers both.
--
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]