Bug 26165 - Type checking in JUnit batchtest
Summary: Type checking in JUnit batchtest
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.6.0
Hardware: Other other
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
Keywords: PatchAvailable
Depends on:
Reported: 2004-01-15 13:00 UTC by Bo Rasmussen
Modified: 2013-09-16 21:24 UTC (History)
1 user (show)

Type checking JUnitTask (3.82 KB, application/octet-stream)
2005-11-03 15:23 UTC, Jeff Badorek

Note You need to log in before you can comment on or make changes to this bug.
Description Bo Rasmussen 2004-01-15 13:00:52 UTC

It would be nice if the batchtest checked the type of a class before running 

We try to enforce that all Test* classes are TestCase classes, but we may have 
occasions where we would like other types of classes to start with Test. The 
batchtest however tries to run the classes as test cases which results in 
failed status for that class, which does not look nice in the test report

Bo Rasmussen
Comment 1 Jeff Badorek 2005-11-03 15:23:02 UTC
Created attachment 16868 [details]
Type checking JUnitTask

This little extension extends the current JUnitTask and uses bcel to do the
type checking you are talking about. It checks that a class extends
junit.framework.TestCase or has a static method called "suite()". In addition,
it also checks that the class is public and not abstract.

I've also added a couple of new properties to include/exclude types to check.
For instance, by default I have includedTypes="junit.framework.TestCase" and
excludedTypes="net.sourceforge.jwebunit.WebTestCase". This way, any class that
extends WebTestCase, won't be run.

All in all, I think that at the very least, the type checking for
"junit.framework.TestCase" could be added to the original JUnitTask.
Comment 2 Stefan Bodewig 2009-07-31 03:59:19 UTC
Of course JUnit4 and Ant's support for it have made most type checks moot.

The "is public and not abstract" part may still be relevant.
Comment 3 Michael Clarke 2013-09-16 21:24:59 UTC
Resolved under revision revision 1523198 with the addition of a 'skipNonTests' attribute to the test and batchtest tasks - Ant now checks tests are either annotated with @Test, @RunWith, or extend TestCase, and are not Abstract