olamy commented on code in PR #3653:
URL: https://github.com/apache/maven-surefire/pull/3653#discussion_r4749277825
##########
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java:
##########
@@ -257,6 +266,29 @@ private void reportAbortedClass(
}
}
+ /**
+ * A method container, like a {@code @ParameterizedTest} or a {@code
@TestFactory}, none of whose invocations got
+ * registered. Invocations that did run were reported on their own, so the
container must not be counted again.
+ * Neither must it when a dynamic container inside it was already counted.
+ */
+ private boolean isMethodContainerWithoutTests(TestIdentifier
testIdentifier) {
+ TestPlan currentTestPlan = testPlan;
+ return
testIdentifier.getSource().filter(MethodSource.class::isInstance).isPresent()
+ && (currentTestPlan == null
+ ||
currentTestPlan.getDescendants(testIdentifier).stream()
+ .noneMatch(d -> d.isTest() ||
countedAbortedContainers.contains(d.getUniqueId())));
+ }
+
+ /**
+ * Outside a rerun, or when this very container failed before. A container
rerun only for one of its
+ * invocations wasn't counted in the first run, so it isn't counted on the
rerun either.
+ */
+ private boolean isRerunForItself(TestIdentifier testIdentifier) {
+ return runMode != RERUN_TEST_AFTER_FAILURE
+ || rerunTestIds.isEmpty()
+ ||
rerunTestIds.contains(UniqueId.parse(testIdentifier.getUniqueId()));
Review Comment:
Good catch, fixed in 431b409ba. On a rerun, an aborted method container now
counts when it's a rerun target itself or sits inside one, for example when its
class failed in `@BeforeAll`. It still doesn't count when it's only rerun for
one of its invocations, because run 1 never counted it. If it was counted in
run 1 too, it keeps the same run id, so the two runs merge into one entry.
`rerunOfAClassCountsItsAbortedMethodContainer` covers your case, and
`rerunOfOneInvocationDoesNotCountItsAbortedContainer` still passes.
--
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]