You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Peter Lynch (JIRA)" <ji...@codehaus.org> on 2012/10/29 05:21:13 UTC
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Peter Lynch created SUREFIRE-917:
------------------------------------
Summary: [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
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Posted by "Peter Lynch (JIRA)" <ji...@codehaus.org>.
[ 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
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Posted by "Peter Lynch (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/SUREFIRE-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312554#comment-312554 ]
Peter Lynch commented on SUREFIRE-917:
--------------------------------------
Anders, if I give surefire {{-Dgroups=Slow}} ( using class simple name matching ) and the actual group interface used in my test is {{some.long.package.name.not.in.groups.config.Slow}}, how is it reasonable that surefire fails with ClassNotFoundException for a class called {{Slow}}?
The point is surefire is supposed to ( according to existing tests ) support matching with {{some.long.package.name.not.in.groups.config.Slow.getSimpleName().endsWith("Slow")}}, but before it was getting to that check, was trying to look up class name called "Slow" in the default package.
> [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
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Posted by "Peter Lynch (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/SUREFIRE-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312565#comment-312565 ]
Peter Lynch commented on SUREFIRE-917:
--------------------------------------
IMO this whole thing is missing surefire killer feature that is not documented. ;)
> [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
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Posted by "Anders Hammar (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/SUREFIRE-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312551#comment-312551 ]
Anders Hammar commented on SUREFIRE-917:
----------------------------------------
But the ClassNotFoundException is due to a misconfiguration where a group/category classname is specified that doesn't exist. Surefire is not failing because it can't find any tests marked with this group.
> [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
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Posted by "Peter Lynch (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/SUREFIRE-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312611#comment-312611 ]
Peter Lynch commented on SUREFIRE-917:
--------------------------------------
Hmm, even though all existing tests pass with these changes, integration test is probably missing somewhere since I just got this using 2.12.4 of surefire:
surefire maven plugin configured with
{noformat}
<groups>org.sonatype.sisu.litmus.testsupport.group.Slow</groups>
<failIfNoTests>false</failIfNoTests>
{noformat}
{noformat}
Running org.junit.runner.manipulation.Filter
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.003 sec <<< FAILURE!
initializationError(org.junit.runner.manipulation.Filter) Time elapsed: 0.003 sec <<< ERROR!
java.lang.Exception: No tests found matching *org.sonatype.sisu.litmus.testsupport.group.Slow from org.junit.runner.Request$1@53ebd75b
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:37)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:62)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
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)
{noformat}
So it appears that if surefire is not respecting {{failIfNoTests}} configuration when using explicit groups, which makes getting matches by simple name in my use case basically broken again.
> [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
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Posted by "Anders Hammar (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/SUREFIRE-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312629#comment-312629 ]
Anders Hammar commented on SUREFIRE-917:
----------------------------------------
@Peter: I think you should file a separate ticket for this. Probably easier to track it then than if including it here.
> [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
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Posted by "Anders Hammar (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/SUREFIRE-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312515#comment-312515 ]
Anders Hammar commented on SUREFIRE-917:
----------------------------------------
Executing with an incorrect category name would be a configuration error and I think it's important to signal this to the user. So just ignoring this it not a good solution IMO. Possibly, having a very visible warning displayed in the console could work.
> [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
[jira] (SUREFIRE-917) [junit] category simple name matching fails
throwing ClassNotFoundException
Posted by "Anders Hammar (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/SUREFIRE-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312558#comment-312558 ]
Anders Hammar commented on SUREFIRE-917:
----------------------------------------
I see. As the documentation doesn't state anything else (like what you say the tests say) I supposed you had to specify the full class name. But I just recently ran into this one as well so I can agree that simple name would be good to support as well. But "endsWith"? I would guess that could cause problems unless people are aware of that.
So, I agree that the ClassNotFound needs to be fixed. Also, the docs for the groups param needs to clearly specify what is supported. And maybe an example...:-) I could help with the docs at least if I only knew what we should support.
> [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