Copilot commented on code in PR #3647:
URL: https://github.com/apache/maven-surefire/pull/3647#discussion_r4733816272


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/lastfailed/LastFailedTestsResolver.java:
##########
@@ -176,12 +181,28 @@ public LastFailedTests resolve(Collection<String> 
scannedClasses, TestListResolv
         for (String className : wholeClasses) {
             tests.addAll(wholeClassPatterns(className, userFilter));
         }
+        // Naming a method turns on the fork's method filter, which checks 
each test by its own class: next to a
+        // class we run whole, it would leave out its @Nested classes, and the 
reports can't always tell us those.
+        // So then we run the class of each failed method whole instead. Not 
when -Dtest names methods itself, the
+        // nested classes didn't run with their class in the first place.
+        boolean nameMethods = wholeClasses.isEmpty() || 
userFilter.hasMethodPatterns();

Review Comment:
   With a lifecycle failure in `FooTest`, a failed method in `BarTest`, and 
`-Dtest=FooTest,BarTest,!FooTest$Other`, the new class-only selection can rerun 
the excluded `@Nested` class `FooTest$Other`. Removing all method patterns 
disables `TestMethodFilter` in `JUnitPlatformProvider.newFilters()`, while the 
remaining class-name filter cannot distinguish this exclusion from the nested 
classes already unmatched by the outer-class includes. Enforce nested 
exclusions independently of method inclusion filtering, and add an integration 
test for this combination.



-- 
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]

Reply via email to