JUnit suite() method ends up being called twice when tests are run with Surefire
--------------------------------------------------------------------------------

         Key: SUREFIRE-47
         URL: http://jira.codehaus.org/browse/SUREFIRE-47
     Project: surefire
        Type: Bug

    Versions: 2.0    
 Environment: maven 2.0.4, ant 1.6.5, this is on MacOSX 10.4.6
    Reporter: toli kuznets
 Attachments: surefireBug.tar

JUnit defines that the static suite() method is only instantiated once.

However, the recent release of surefire (2.0) seems to call the suite() method 
twice. 
the first time it's called from during the creation of all suites (see the 
first stacktrace in the attached test.out files) - the JUnitTestSet calls 
"suite()" to instantiate a test object so that it can call countTestCases() on 
it. 

The second time the suite() method is called during the actual test execution, 
when Surefire.run() iterates over all the collected test suites and eventually 
calls into JUnitTestSet.execute() method.

a sample project is attached. I added an exception stacktrace into every 
occurence of the suite() method.

there's also a build.xml file to run the 'ant test' command for comparison. 

There's also a test.out file with the sample output.

Suggested fixes:
Is it possible to pass the suite itself to the JUnitTestSet w/out having to 
create it again? 
We rely on suite() being called only once, and create one-time operations there 
(such as creating a few singletons) so this bug is a pain.



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