Currently Ant's <junit> is designed for JUnit 3.x. It is possible to run JUnit 4 tests (i.e. those which use annotations and do not extend TestCase) only if you pollute your test code with the otherwise unnecessary public static Test suite() { return new JUnit4TestAdapter(ThisTest.class); } Otherwise, running under Ant 1.6.5 you just get junit.framework.AssertionFailedError: No tests found in MyTest Ant can be patched to always accept JUnit 3.x tests, and to also accept "pure" JUnit 4.x tests when junit-4.0.jar is in the classpath. Note that in the latter case you _must_ be running on JDK 5 or later; even the "legacy" classes use the JDK 5 classfile format. Not terribly complicated but involves a bit of fine-tuning since the two frameworks have some subtle differences. Patch tries to accomplish: 1. No change in behavior when using junit-3.x.jar. 2. Use junit-4.0.jar to run JUnit 3.x tests transparently in compatibility mode. Use junit-4.0.jar to run JUnit 4.x tests transparently (currently also in compatibility mode, to keep the task relatively simple). No user configuration or change in <junit> task signature. 3. Treat Assert.* failures as real failures, not errors. 4. Use the @Test-annotated method name as the test case name in the expected way.
Created attachment 17809 [details] Manual test case Checks successes, failures, and errors in 3-type and 4-type test classes. Output ought to look similar.
revision 381780
Tweak in revision 382127.
*** Bug 40289 has been marked as a duplicate of this bug. ***
*** Bug 40406 has been marked as a duplicate of this bug. ***