You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2012/03/15 22:14:47 UTC

DO NOT REPLY [Bug 52923] New: JUnit4 test should not run as JUnit3 if annotated RunWith

https://issues.apache.org/bugzilla/show_bug.cgi?id=52923

             Bug #: 52923
           Summary: JUnit4 test should not run as JUnit3 if annotated
                    RunWith
           Product: Ant
           Version: 1.8.2
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Optional Tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: staxd@web.de
    Classification: Unclassified


Created attachment 28476
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28476
ZIP containing diff, Example test, build.xml for reproduction

Since ant 1.8.2, the junit task runs JUnit4 tests with annotation @RunWith as
JUnit3 test if test is derived from junit.framework.TestCase. Tests like that
are not uncommon during migration from JUnit3 to JUnit4. The bug did not occur
in ant 1.8.1 and is still present in ant 1.8.3.

The reason is that class JUnitTestRunner has been changed to use JUnit3 if the
test extends junit.framework.TestCase (while not taking into account any
@RunWith annotation.)

I propose the attached patch of JUnitTestRunner (diff -u) which detects any
RunWith annotation and switches to JUnit4 if present. I also attach an Example
test and a build.xml to simplify reproduction.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.