[
https://jira.codehaus.org/browse/SUREFIRE-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312549#comment-312549
]
Peter Lynch commented on SUREFIRE-917:
--------------------------------------
Not sure if it is suitable to warn. Consider that in a multimodule
configuration I am sharing surefire config, and define a set of groups to run.
Some modules may have tests with this category, some not. This is perfectly
reasonably and I don't want a bunch of noise from Maven about a problem which
is totally by intention and supported by group pattern matching.
The most I could see is at Maven debug level, mentioning the list of single
group name patterns which did not contribute to selecting tests to execute.
This could help one diagnose a potential problem should someone be curious why
certain tests were not being run by surefire.
However I am personally unclear where I could add such code to the group
matching logic and print it to Maven logs.
> [junit] category simple name matching fails throwing ClassNotFoundException
> ---------------------------------------------------------------------------
>
> Key: SUREFIRE-917
> URL: https://jira.codehaus.org/browse/SUREFIRE-917
> Project: Maven Surefire
> Issue Type: Bug
> Components: Junit 4.x support
> Affects Versions: 2.12.4
> Reporter: Peter Lynch
> Attachments: fix_support_for_junit_simple_group_name_matching.patch
>
>
> According to a [unit test I
> found|https://git-wip-us.apache.org/repos/asf?p=maven-surefire.git;a=blob;f=surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java;h=e92595a09de1eb706f54c70b8efe8df592e40ec5;hb=HEAD#l134]
> JUnit categories/group support should allow matching groups by the category
> interface simple name along with the fully qualified name.
> Example , given category interfaces:
> {noformat}
> category.Fast
> category.Slow
> {noformat}
> The following commands should be equivalent:
> {noformat}
> mvn test -Dgroups="Slow,Fast"
> mvn test -Dgroups="category.Slow,category.Fast"
> mvn test -Dgroups="category.Slow.class,category.Fast.class"
> {noformat}
> In my testing, the first command does not work. Instead I get the following
> exception:
> {noformat}
> org.apache.maven.surefire.util.SurefireReflectionException:
> java.lang.reflect.InvocationTargetException; nested exception is
> java.lang.reflect.InvocationTargetException: null
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
> at
> org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
> at
> org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
> at
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
> at
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
> Caused by: java.lang.RuntimeException: Unable to load category: Fast
> at
> org.apache.maven.surefire.group.match.SingleGroupMatcher.loadGroupClasses(SingleGroupMatcher.java:134)
> at
> org.apache.maven.surefire.group.match.JoinGroupMatcher.loadGroupClasses(JoinGroupMatcher.java:44)
> at
> org.apache.maven.surefire.common.junit48.FilterFactory.createGroupFilter(FilterFactory.java:92)
> at
> org.apache.maven.surefire.junitcore.JUnitCoreProvider.createJUnit48Filter(JUnitCoreProvider.java:183)
> at
> org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:115)
> ... 9 more
> Caused by: java.lang.ClassNotFoundException: Fast
> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> at
> org.apache.maven.surefire.group.match.SingleGroupMatcher.loadGroupClasses(SingleGroupMatcher.java:130)
> ... 13 more
> {noformat}
> It seems like if a category name cannot be loaded, it should just be ignored.
> I added an integration test that proves the failure and supplied a patch
> which avoids the problem to allow specifying the simple class name for
> matching.
> It would be great to have this working to allow a developer to easily run
> specific groups of tests in a concise manner.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira