DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38811>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38811

           Summary: Support JUnit 4
           Product: Ant
           Version: 1.6.5
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Optional Tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: dev@ant.apache.org,[EMAIL PROTECTED]


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.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to