ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgl...@apache.org
Subject svn commit: r411044 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit: JUnitVersionHelper.java XMLJUnitResultFormatter.java
Date Fri, 02 Jun 2006 05:27:26 GMT
Author: jglick
Date: Thu Jun  1 22:27:26 2006
New Revision: 411044

URL: http://svn.apache.org/viewvc?rev=411044&view=rev
Log:
Stefan pointed out that the XML formatter was mistakenly using "JUnit4TestFacade"
as the "class name" for simple TestCase's run under JUnit 4.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java?rev=411044&r1=411043&r2=411044&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
Thu Jun  1 22:27:26 2006
@@ -93,4 +93,22 @@
         return "unknown";
     }
 
+    /**
+     * Tries to find the name of the class which a test represents
+     * across JUnit 3 and 4.
+     */
+    static String getTestCaseClassName(Test test) {
+        String className = test.getClass().getName();
+        if (className.equals("junit.framework.JUnit4TestCaseFacade")) {
+            // JUnit 4 wraps solo tests this way. We can extract
+            // the original test name with a little hack.
+            String name = test.toString();
+            int paren = name.lastIndexOf('(');
+            if (paren != -1 && name.endsWith(")")) {
+                className = name.substring(paren + 1, name.length() - 1);
+            }
+        }
+        return className;
+    }
+
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java?rev=411044&r1=411043&r2=411044&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
Thu Jun  1 22:27:26 2006
@@ -200,7 +200,7 @@
             // a TestSuite can contain Tests from multiple classes,
             // even tests with the same name - disambiguate them.
             currentTest.setAttribute(ATTR_CLASSNAME,
-                                     test.getClass().getName());
+                    JUnitVersionHelper.getTestCaseClassName(test));
             rootElement.appendChild(currentTest);
             testElements.put(test, currentTest);
         } else {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message