gnodet commented on code in PR #3554:
URL: https://github.com/apache/maven-surefire/pull/3554#discussion_r4792357350


##########
surefire-api/src/main/java/org/apache/maven/surefire/api/testset/ResolvedTest.java:
##########
@@ -316,6 +323,49 @@ static String fromFullyQualifiedClass(String cls) {
         }
     }
 
+    /**
+     * Tells whether the name in front of a trailing {@code .*} wildcard, e.g. 
{@code another.package}
+     * in {@code another.package.*} or {@code dev} in {@code dev.*}, denotes a 
package rather than a
+     * class. The dot notation does not distinguish the two: {@code 
my.pkg.MyTest.*} means "class
+     * MyTest and its nested classes" while {@code another.package.*} means 
"every class in this
+     * package", and only the last segment tells them apart. By Java naming 
convention a package name
+     * starts with a lowercase letter and a class name starts with an 
uppercase letter, so that
+     * convention is used to resolve the ambiguity, consistent with the {@code 
another.package.*}
+     * example from the plugin documentation. This is only a best guess: 
{@link ClassMatcher} also
+     * matches the legacy class-file interpretation alongside the package one, 
so a class name that
+     * violates the convention still matches itself.

Review Comment:
   **Excellent documentation!** 👍
   
   The javadoc here clearly explains:
   - The ambiguity in dot notation
   - Why naming convention is used as the heuristic
   - That the fallback ensures backward compatibility even when naming 
conventions are violated
   
   This level of detail will be invaluable for future maintainers.



##########
surefire-api/src/main/java/org/apache/maven/surefire/api/testset/ResolvedTest.java:
##########
@@ -316,6 +323,49 @@ static String fromFullyQualifiedClass(String cls) {
         }
     }
 
+    /**
+     * Tells whether the name in front of a trailing {@code .*} wildcard, e.g. 
{@code another.package}
+     * in {@code another.package.*} or {@code dev} in {@code dev.*}, denotes a 
package rather than a
+     * class. The dot notation does not distinguish the two: {@code 
my.pkg.MyTest.*} means "class
+     * MyTest and its nested classes" while {@code another.package.*} means 
"every class in this
+     * package", and only the last segment tells them apart. By Java naming 
convention a package name
+     * starts with a lowercase letter and a class name starts with an 
uppercase letter, so that
+     * convention is used to resolve the ambiguity, consistent with the {@code 
another.package.*}
+     * example from the plugin documentation. This is only a best guess: 
{@link ClassMatcher} also
+     * matches the legacy class-file interpretation alongside the package one, 
so a class name that
+     * violates the convention still matches itself.
+     *
+     * @param dottedName dotted name with the trailing {@code .*} wildcard 
already stripped
+     * @return {@code true} if the last segment of {@code dottedName} looks 
like a package name
+     */
+    private static boolean isPackageName(String dottedName) {
+        String lastSegment = dottedName.substring(dottedName.lastIndexOf('.') 
+ 1);
+        return !lastSegment.isEmpty() && 
Character.isLowerCase(lastSegment.charAt(0));

Review Comment:
   **Minor: Edge case with special character prefixes**
   
   The use of `Character.isLowerCase()` to determine if a segment is a package 
name works well for standard Java naming conventions. However, for identifiers 
starting with special characters like underscore (e.g., `_test`), this returns 
`false`, treating them as class names.
   
   Example: `org.example._test.*` would be treated as a class wildcard rather 
than a package wildcard.
   
   Since this violates Java naming conventions anyway and the fallback matching 
mechanism handles it, this is not a blocker—just worth noting for completeness. 
The current implementation is pragmatic and follows the documented conventions.



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