You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-dev@maven.apache.org by Dan Fabulich <da...@fabulich.com> on 2007/11/24 03:29:38 UTC

Running suite() twice

SUREFIRE-47 points out, correctly, that we're running the suite() method 
twice: once to count the tests, and then again when the tests actually 
run.

http://jira.codehaus.org/browse/SUREFIRE-47

This happens in JUnitTestSet; what's strange is that we don't do this in 
TestNGTestSet.  "getTestCount()" simply returns 1 in that case, with a 
TODO "need to get this from TestNG somehow".  This is filed as 
SUREFIRE-94; it's minor, because "this isn't required for correct 
operation of the tests, but may be if a reporter relies on the correct 
number in the runStarting method (currently, it is unused)."

If so, why do we count the tests initially at all?  I just tried ripping 
out all implementations of getTestCount() and just adding 1 to totalTests 
whenever we would have called it.  It doesn't seem to have done any harm; 
the only difference I can see is that in the case where you've got some 
classes that look like tests, we do "execute" the test run, but when we 
find no tests, the summary banner says:

   Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

... instead of:

   No tests to run.

(It still says "No tests to run" when there are no JUnit classes at all.)

Therefore, I'm inclined to fix SUREFIRE-47 by ripping out getTestCount() 
from the SurefireTestSet interface and removing its implementation from 
JUnitTestSet, PojoTestSet and TestNGTestSet.

Does anyone object to this?

-Dan

Re: Running suite() twice

Posted by Brett Porter <br...@apache.org>.
Sounds ok to me. I was trying to maintain it since it existed before,  
but it's clearly not used in a useful way.

On 24/11/2007, at 10:29 AM, Dan Fabulich wrote:

>
> SUREFIRE-47 points out, correctly, that we're running the suite()  
> method twice: once to count the tests, and then again when the  
> tests actually run.
>
> http://jira.codehaus.org/browse/SUREFIRE-47
>
> This happens in JUnitTestSet; what's strange is that we don't do  
> this in TestNGTestSet.  "getTestCount()" simply returns 1 in that  
> case, with a TODO "need to get this from TestNG somehow".  This is  
> filed as SUREFIRE-94; it's minor, because "this isn't required for  
> correct operation of the tests, but may be if a reporter relies on  
> the correct number in the runStarting method (currently, it is  
> unused)."
>
> If so, why do we count the tests initially at all?  I just tried  
> ripping out all implementations of getTestCount() and just adding 1  
> to totalTests whenever we would have called it.  It doesn't seem to  
> have done any harm; the only difference I can see is that in the  
> case where you've got some classes that look like tests, we do  
> "execute" the test run, but when we find no tests, the summary  
> banner says:
>
>   Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
>
> ... instead of:
>
>   No tests to run.
>
> (It still says "No tests to run" when there are no JUnit classes at  
> all.)
>
> Therefore, I'm inclined to fix SUREFIRE-47 by ripping out  
> getTestCount() from the SurefireTestSet interface and removing its  
> implementation from JUnitTestSet, PojoTestSet and TestNGTestSet.
>
> Does anyone object to this?
>
> -Dan

--
Brett Porter - brett@apache.org
Blog: http://www.devzuz.org/blogs/bporter/