Copilot commented on code in PR #3454:
URL: https://github.com/apache/maven-surefire/pull/3454#discussion_r3996097265
##########
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java:
##########
@@ -268,6 +277,35 @@ private static boolean isClassContainer(TestIdentifier
testIdentifier) {
.isPresent();
}
+ /**
+ * Whether this class container should open/close a Surefire test set.
+ * Top-level classes do; {@code @Nested} ClassSource containers do not,
because they
+ * report under the outer class {@code sourceName} and would otherwise
reset/overwrite
+ * the outer TXT summary (#3356).
+ */
+ private boolean isSurefireTestSetContainer(TestIdentifier testIdentifier) {
+ if (!isClassContainer(testIdentifier)) {
+ return false;
+ }
+ // Top-level for Surefire = no ancestor ClassSource container.
+ // Name equality is wrong for JUnit 6 parameterized-class invocations:
both the
+ // template and each invocation are ClassSource containers with the
same
+ // sourceName/qualifiedClassName, so invocations would still open test
sets (#3356).
+ TestPlan currentTestPlan = testPlan;
+ if (currentTestPlan == null) {
+ return true;
+ }
+ Optional<TestIdentifier> parent =
currentTestPlan.getParent(testIdentifier);
+ while (parent.isPresent()) {
+ TestIdentifier ancestor = parent.get();
+ if (isClassContainer(ancestor)) {
+ return false;
+ }
+ parent = currentTestPlan.getParent(ancestor);
+ }
+ return true;
Review Comment:
This treats every `ClassSource` ancestor as the same test-set hierarchy, but
a JUnit Platform `@Suite` also has a `ClassSource` suite descriptor above a
nested Jupiter engine. In the existing suite shape
(`RunListenerAdapterTest.java:1042-1083`), the actual selected test class
therefore returns false here, so its test set never starts or completes; with
JUnit Platform's per-source statistics enabled
(`AbstractSurefireMojo.java:2204-2207`), its TXT stats are never flushed and
are attributed to the suite's empty set instead. Use the existing
engine-boundary-aware `findTopParent` logic so true `@Nested` classes remain in
the outer set without suppressing classes below a nested engine.
--
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]