[ 
http://jira.codehaus.org/browse/SUREFIRE-482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=229314#action_229314
 ] 

Kristian Rosenvold commented on SUREFIRE-482:
---------------------------------------------

Thanks for the patch, Tom.

As can be seen from several of the comments to this issue, there is the problem 
that this bug has been around long enough to become a feature (pardon the pun). 
I also know from experience that this "feature" is used by quite a lot of 
projects.

I believe that any patch to this issue will need to include one or more of the 
following features:
A) Solve the issue by making the provider-switch more explicit (i.e. leave 4.x 
provider as-is)
B) Solve 4.x problem more or less as you suggest, but provide log warnings 
about classes that will not be run any more due to behavior change. While this 
initially may seem like a nice fix, the problem is that the message will have 
to be more or less permanently in place - which means we'll be nagging users 
indefinitely due to what is basically a bug.
C) Make some kind of "strictJunit4classscanning" attribute on surefire plugin 
that allows the correct behavior to be turned on/off. 

I'm sure there's may be other ways to fix this, but I think the fix (in one way 
or another) needs to respect that it's become somewhat of a "feature".

There also needs to be an integration test for whatever fix is chosen, after 
all it's a test framework ;)


> Surefire tries to run JUnit4 tests that contain no @Test annotations
> --------------------------------------------------------------------
>
>                 Key: SUREFIRE-482
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-482
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.x support
>    Affects Versions: 2.4.2
>            Reporter: Mark Hobson
>         Attachments: JUnit4DirectoryTestSuite.java, test.zip
>
>
> Similar to SUREFIRE-346 but for JUnit4, Surefire tries to run classes that 
> contain no @Test annotations as tests, resulting in the exception:
> java.lang.Exception: No runnable methods
>         at 
> org.junit.internal.runners.MethodValidator.validateInstanceMethods(MethodValidator.java:32)
>         at 
> org.junit.internal.runners.MethodValidator.validateMethodsForDefaultRunner(MethodValidator.java:43)
>         at 
> org.junit.internal.runners.JUnit4ClassRunner.validate(JUnit4ClassRunner.java:36)
>         at 
> org.junit.internal.runners.JUnit4ClassRunner.<init>(JUnit4ClassRunner.java:27)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method)
>         at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>         at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>         at 
> org.junit.internal.requests.ClassRequest.buildRunner(ClassRequest.java:33)
>         at 
> org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:28)
>         at 
> org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:45)
>         at 
> org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)
>         at 
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)
>         at 
> org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)
>         at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
>         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:585)
>         at 
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
>         at 
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
> Such classes should be ignored by Surefire.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to