Issue Details (XML | Word | Printable)

Key: SUREFIRE-120
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Mike Perham
Reporter: Dan Fabulich
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Maven Surefire

When you <include> a JUnit TestSuite (with no test methods), no tests are run

Created: 16/May/06 08:52 PM   Updated: 21/Jan/07 04:01 PM
Component/s: None
Affects Version/s: 2.0 (2.2 plugin)
Fix Version/s: 2.3

Time Tracking:
Not Specified

File Attachments: 1. Text File MSUREFIRE-113.patch (2 kB)
2. Zip Archive suitebug.zip (3 kB)
3. Java Archive File surefire-junit-2.1-SNAPSHOT.jar (12 kB)


Testcase included: yes


 Description  « Hide
In the attached Maven project, I started with the default Maven getting started archetype and then created an AppTestSuite class, which extends TestSuite and defines the static suite() method, but it has no test methods of its own. Then I added an <includes> configuration that specified <includes><include>**/AppTestSuite.java</include></includes>. But when I run "mvn test", it claims that "There are no tests to run."

I've watched this happening in a debugger. The problem is in surefire-api-2.0.jar in PojoTestSet , on line 249. When attempting to acquire a list of the number of tests to run, instead of invoking the suite method and counting the number of tests that come out, it's attempting to discoverTestMethods on the object (methods whose names begin with "test*"), which naturally won't work for suites.

This is a really serious issue that's going to block testing for us. (We happen to attach a TestSetup decorator to our suite, so we do need to run these tests as a suite rather than as individual test cases.)



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Dan Fabulich added a comment - 16/May/06 09:29 PM
At a suggestion from groves on IRC, I tried making my AppTestSuite class extend TestCase instead of TestSuite. This forced surefire to count the test cases correctly, and was an effective workaround for my project.

Charlie Groves added a comment - 16/May/06 09:44 PM
If JUnitDirectoryTestSuite checked against Test instead of TestCase in its isAssignableFrom test, this wouldn't be an issue. From what I can tell in JUnitTestSet, having the testClasses passed to the constructor consist of anything that implements Test wouldn't be a problem as JUnitTestSet only uses the run and countTestMethods methods.

Mike Perham added a comment - 17/May/06 11:14 AM
Charlie, excellent detective work. I made your suggested changes and found this fixes the problem (I replaced my surefire-junit-2.0.jar with the attached snapshot). I do not have commit privileges to the surefire source so this patch will need to be reviewed and committed by someone else.

Brett Porter added a comment - 17/May/06 12:39 PM
this also should be changed in the TestNG provider

Mike Perham added a comment - 17/May/06 03:14 PM
Updated surefire-junit and surefire-testng.