ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38811] New: - Support JUnit 4
Date Tue, 28 Feb 2006 20:50:37 GMT
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: jglick@netbeans.org
        ReportedBy: jglick@netbeans.org
                CC: dev@ant.apache.org,mpetras@netbeans.org


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: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message