Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.2.5
-
None
-
None
Description
As discussed in this users mailing list thread, something like
mvn test -Dtest=dev.aspectj.*
does not work, while
mvn test -Dtest=dev/aspectj/*
does. I.e., the matcher does not treat "/" path separators and "." package separators as equivalent, which IMO it should, also in more complex globbing patterns like
dev.aspectj.**.*
Interestingly, as soon as there is a prefix to the asterisk, it starts working again, e.g.
dev.aspectj.MyO*
Sorry for using code blocks rather than inline code formatting, but Jira has problems with inline asterisk characters outside of code blocks.
One quick fix that fors for me locally, is
--- a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/ResolvedTest.java (revision Staged) +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/ResolvedTest.java (date 1707188275344) @@ -339,7 +339,7 @@ private boolean matchClassPatter(String testClassFile) { // @todo We have to use File.separator only because the MatchPatterns is using it internally - cannot // override. - String classPattern = ResolvedTest.this.classPattern; + String classPattern = ResolvedTest.this.classPattern.replace('.', '/'); if (separatorChar != '/') { testClassFile = testClassFile.replace('/', separatorChar); classPattern = classPattern.replace('/', separatorChar);
I did not thoroughly test it, but at least as a commiter you know where you can start looking.
The reason why this is a patch rather than a PR is that maybe this is the wrong place to replace the dots by slashes. Maybe, that should happen much earlier when parsing the patterns from the test parameter for the first time, if it is clear that they are no regex patterns. I think, the committers here know much better than I.
P.S.: If you are changing anything in that class, maybe you can take the change to correctly rename the two private methods matchClassPatter and matchClassRegexPatter to end with "n".