AzazelSensei commented on code in PR #3432:
URL: https://github.com/apache/maven-surefire/pull/3432#discussion_r3841309628


##########
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java:
##########
@@ -208,6 +208,42 @@ private Stream<TestIdentifier> 
collectAllTestIdentifiersInHierarchy(TestIdentifi
                 .orElseGet(Stream::empty);
     }
 
+    /**
+     * Build a {@code [outer][inner]} suffix from every JUnit Jupiter
+     * {@code [class-template-invocation:#N]} unique-id segment. Nested
+     * {@code @ParameterizedClass} declarations emit more than one; taking only
+     * the last would collapse outer #1/inner #1 with outer #2/inner #1.
+     *
+     * @param uniqueId the platform unique id string
+     * @return the suffix, or an empty string when the id has no 
class-template invocation
+     */
+    private static String extractClassTemplateInvocationSuffix(String 
uniqueId) {
+        if (uniqueId == null) {
+            return "";
+        }
+        String marker = "[class-template-invocation:";

Review Comment:
   Switched this to UniqueId.parse(uniqueId).getSegments() and read the 
class-template-invocation / test-template-invocation values from there.



##########
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java:
##########
@@ -462,14 +498,26 @@ private ResultDisplay toClassMethodName(TestIdentifier 
testIdentifier) {
                     .map(TestIdentifier::getLegacyReportingName)
                     .anyMatch(legacyReportingName -> 
legacyReportingName.matches("^\\[.+]$"));
             boolean isTestTemplate = 
testIdentifier.getLegacyReportingName().matches("^.*\\[\\d+]$");
-
-            boolean parameterized = isParameterized || hasParameterizedParent 
|| isTestTemplate;
+            // JUnit 6 @ParameterizedClass parents have a ClassSource, so they 
are missed by
+            // hasParameterizedParent, and the method legacy name no longer 
includes [N] (#3303).
+            String classTemplateInvocationSuffix = 
extractClassTemplateInvocationSuffix(testIdentifier.getUniqueId());
+
+            boolean parameterized = isParameterized
+                    || hasParameterizedParent
+                    || isTestTemplate
+                    || !classTemplateInvocationSuffix.isEmpty();
             String methodName = methodSource.getMethodName();
             String description = testIdentifier.getLegacyReportingName();
             boolean equalDescriptions = methodDisplay.equals(description);
             boolean hasLegacyDescription = description.startsWith(methodName + 
'(');
             boolean hasDisplayName = !equalDescriptions || 
!hasLegacyDescription;
             String methodDesc = parameterized ? description : methodName;
+            // JUnit 6.1+ already puts the class index before a method 
invocation index

Review Comment:
   Yeah, the contains() check was wrong. foo()[2] from method #2 looked like 
class #2 already, and class #2 / method #1 came out as foo()[1][2]. I rebuild 
from the unique-id segments now, class index first: class #2 / method #1 is 
foo()[2][1].



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