Geoff Denning created SUREFIRE-944:
--------------------------------------

             Summary: Surefire does not execute tests on abstract classes that 
contain static nested classes
                 Key: SUREFIRE-944
                 URL: https://jira.codehaus.org/browse/SUREFIRE-944
             Project: Maven Surefire
          Issue Type: Bug
          Components: Maven Surefire Plugin
    Affects Versions: 2.13
            Reporter: Geoff Denning


If a test class is abstract or interface, but contains a nested concrete static 
class, Surefire won't find the enclosed tests, even when 
@RunWith(Enclosed.class) is specified.  For example:

import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;

@RunWith(Enclosed.class)
public abstract class TopLevelAbstractClassTest {
       public static class InnerTest {
               @Test
               public void testSomething() {
               }
       }
}

The reason why this is an issue is that projects such as Hystrix 
(https://github.com/Netflix/Hystrix) put unit tests inside nested classes in 
the implementation classes.  Currently Hystrix uses Gradle, but I am working to 
Mavenize the project.

The problem appears to be in JUnit4TestChecker.isValidJUnit4Test, which ensures 
that the class is not abstract before checking the RunWith annotation.

I've created an integration test and potential fix which are available here: 
https://github.com/gdenning/maven-surefire/commit/bc376f8dbbd6611bd9a645c8a53c80b4f450aac6

I haven't submitted a pull request yet because the integration tests aren't 
picking up my code changes for some reason so the test is still failing. If I 
get it working I will submit a pull request on GitHub.

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

        

Reply via email to