You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Aslak Knutsen (JIRA)" <ji...@codehaus.org> on 2011/06/02 16:33:22 UTC

[jira] Created: (SUREFIRE-744) NullPointerException in ConcurrentReporterManager, falsely report of "No tests were executed!"

NullPointerException in ConcurrentReporterManager, falsely report of "No tests were executed!"
----------------------------------------------------------------------------------------------

                 Key: SUREFIRE-744
                 URL: http://jira.codehaus.org/browse/SUREFIRE-744
             Project: Maven Surefire
          Issue Type: Bug
          Components: Junit 4.7+ (parallel) support
    Affects Versions: 2.8.1
            Reporter: Aslak Knutsen
         Attachments: MavenSurefireJUnit47RunnerTestCase.java

See SUREFIRE-629, same result, just this time the assumption is on the use of multiple @Ignore test cases

JUnitCoreRunListener.fillTestCountMap prefill a Map with all the Descriptions for this testrun, but it gets a bit confused when multiple tests use @Ignore on Class Level. 

JUnit will report these as Description.isTest because they have no children, but they are not, all their children are ignored.
So these are added as Methods to some other Class, which means the TestSet Class lookup on testSkipped results in null.


a possible crude fix would be:

{code:title=org.apache.maven.surefire.junitcore.JUnitCoreRunListener}
    private void fillTestCountMap( Description description )
    {
        final ArrayList<Description> children = description.getChildren();

        TestSet testSet = new TestSet( description );
        Class<?> itemTestClass = null;
        for ( Description item : children )
        {
            if ( item.isTest() && item.getMethodName() != null)
            {
                testSet.incrementTestMethodCount();
                if ( itemTestClass == null )
                {
                    itemTestClass = item.getTestClass();
                }
            }
            else if ( item.getChildren().size() > 0 )
            {
                fillTestCountMap( item );
            }
            else 
            {
            	classMethodCounts.put( item.getClassName(), testSet );
            }
        }
        if ( itemTestClass != null )
        {
            classMethodCounts.put( itemTestClass.getName(), testSet );
        }
    }
{code}

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

        

[jira] Updated: (SUREFIRE-744) NullPointerException in ConcurrentReporterManager, falsely report of "No tests were executed!"

Posted by "Aslak Knutsen (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/SUREFIRE-744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aslak Knutsen updated SUREFIRE-744:
-----------------------------------

    Attachment: MavenSurefireJUnit47RunnerTestCase.java

TestCase showing the issue

> NullPointerException in ConcurrentReporterManager, falsely report of "No tests were executed!"
> ----------------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-744
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-744
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.7+ (parallel) support
>    Affects Versions: 2.8.1
>            Reporter: Aslak Knutsen
>         Attachments: MavenSurefireJUnit47RunnerTestCase.java
>
>
> See SUREFIRE-629, same result, just this time the assumption is on the use of multiple @Ignore test cases
> JUnitCoreRunListener.fillTestCountMap prefill a Map with all the Descriptions for this testrun, but it gets a bit confused when multiple tests use @Ignore on Class Level. 
> JUnit will report these as Description.isTest because they have no children, but they are not, all their children are ignored.
> So these are added as Methods to some other Class, which means the TestSet Class lookup on testSkipped results in null.
> a possible crude fix would be:
> {code:title=org.apache.maven.surefire.junitcore.JUnitCoreRunListener}
>     private void fillTestCountMap( Description description )
>     {
>         final ArrayList<Description> children = description.getChildren();
>         TestSet testSet = new TestSet( description );
>         Class<?> itemTestClass = null;
>         for ( Description item : children )
>         {
>             if ( item.isTest() && item.getMethodName() != null)
>             {
>                 testSet.incrementTestMethodCount();
>                 if ( itemTestClass == null )
>                 {
>                     itemTestClass = item.getTestClass();
>                 }
>             }
>             else if ( item.getChildren().size() > 0 )
>             {
>                 fillTestCountMap( item );
>             }
>             else 
>             {
>             	classMethodCounts.put( item.getClassName(), testSet );
>             }
>         }
>         if ( itemTestClass != null )
>         {
>             classMethodCounts.put( itemTestClass.getName(), testSet );
>         }
>     }
> {code}

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

        

[jira] Closed: (SUREFIRE-744) NullPointerException in ConcurrentReporterManager, falsely report of "No tests were executed!"

Posted by "Kristian Rosenvold (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/SUREFIRE-744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Rosenvold closed SUREFIRE-744.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.9

Fixed in r1132734 with your exact patch, thanks !

I opted to generalize/extend one of the existing integration tests over your supplied unit test. This is not because I prefer integration tests over unit tests, but there is still some work that needs to be done on initialization of the unit-test fixtures before I think these can be written nicely and in a maintainable way. (your tests are basically based on other tests that were written by me so this is basically a critique of my own work ;)

So currently the integration tests keep a good focus on the end-to-end feature being tested in a quite simple if somewhat slow-running way (run with -Pparallel profile). The unit tests tend to get very bogged down in all sorts of complex construction, although I imagine a few well-placed factory methods could change that radically. 

I don't seem to be getting the time to to get round to that, so any patches attempting to simplify/beautify the unit-test setup phase will have my full attention



 



> NullPointerException in ConcurrentReporterManager, falsely report of "No tests were executed!"
> ----------------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-744
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-744
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.7+ (parallel) support
>    Affects Versions: 2.8.1
>            Reporter: Aslak Knutsen
>            Assignee: Kristian Rosenvold
>             Fix For: 2.9
>
>         Attachments: MavenSurefireJUnit47RunnerTestCase.java
>
>
> See SUREFIRE-629, same result, just this time the assumption is on the use of multiple @Ignore test cases
> JUnitCoreRunListener.fillTestCountMap prefill a Map with all the Descriptions for this testrun, but it gets a bit confused when multiple tests use @Ignore on Class Level. 
> JUnit will report these as Description.isTest because they have no children, but they are not, all their children are ignored.
> So these are added as Methods to some other Class, which means the TestSet Class lookup on testSkipped results in null.
> a possible crude fix would be:
> {code:title=org.apache.maven.surefire.junitcore.JUnitCoreRunListener}
>     private void fillTestCountMap( Description description )
>     {
>         final ArrayList<Description> children = description.getChildren();
>         TestSet testSet = new TestSet( description );
>         Class<?> itemTestClass = null;
>         for ( Description item : children )
>         {
>             if ( item.isTest() && item.getMethodName() != null)
>             {
>                 testSet.incrementTestMethodCount();
>                 if ( itemTestClass == null )
>                 {
>                     itemTestClass = item.getTestClass();
>                 }
>             }
>             else if ( item.getChildren().size() > 0 )
>             {
>                 fillTestCountMap( item );
>             }
>             else 
>             {
>             	classMethodCounts.put( item.getClassName(), testSet );
>             }
>         }
>         if ( itemTestClass != null )
>         {
>             classMethodCounts.put( itemTestClass.getName(), testSet );
>         }
>     }
> {code}

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