You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Kristian Rosenvold (JIRA)" <ji...@codehaus.org> on 2013/05/03 21:07:53 UTC

[jira] (SUREFIRE-944) Surefire does not execute tests on abstract classes that contain static nested classes

     [ https://jira.codehaus.org/browse/SUREFIRE-944?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Rosenvold closed SUREFIRE-944.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.15
         Assignee: Kristian Rosenvold

Thanks for the suggested patch and test case!

Patch applied with significant modifications in b45fb4a46322c934edc9f8cc5391723eadbcd00d.

                
> 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
>            Assignee: Kristian Rosenvold
>             Fix For: 2.15
>
>
> 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
For more information on JIRA, see: http://www.atlassian.com/software/jira