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


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/lastfailed/LastFailedTestsResolver.java:
##########
@@ -176,14 +181,26 @@ public LastFailedTests resolve(Collection<String> 
scannedClasses, TestListResolv
         for (String className : wholeClasses) {
             tests.addAll(wholeClassPatterns(className, userFilter));
         }
+        List<String> failedMethodPatterns = new ArrayList<>();
         int failedMethodCount = 0;
+        boolean allInWholeClasses = true;
         for (Map.Entry<String, Set<String>> entry : failedMethods.entrySet()) {
+            String className = entry.getKey();
             // no need to list the failed methods of a class we run whole
-            if (!wholeClasses.contains(entry.getKey())) {
-                tests.add(entry.getKey() + "#" + String.join("+", 
entry.getValue()));
+            if (!wholeClasses.contains(className)) {
+                failedMethodPatterns.add(className + "#" + String.join("+", 
entry.getValue()));
                 failedMethodCount += entry.getValue().size();
+                allInWholeClasses &= enclosingClasses(className, 
reportClasses.get(className)).stream()
+                        .anyMatch(wholeClasses::contains);
             }
         }
+        // The same goes for the nested classes of a class we run whole, but 
only when no method gets named:
+        // that would turn on the method filter in the fork and leave the 
other nested tests out.
+        if (allInWholeClasses && !userFilter.hasMethodPatterns()) {
+            failedMethodPatterns.clear();
+            failedMethodCount = 0;
+        }

Review Comment:
   When a whole-class retry is mixed with a method retry, the generated 
selection can omit nested tests from the class that should run whole. For 
example, `pkg.FooTest,pkg.BarTest#x,pkg.FooTest$Inner#m` enables 
`TestMethodFilter`, which rejects every other method in `FooTest$Inner` despite 
the whole-class retry for `FooTest`. Preserve all nested descendants covered by 
whole-class retries when emitting method patterns, while respecting user 
filters, and add an integration regression for this mixed case.



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