ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r704571 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
Date Tue, 14 Oct 2008 16:05:17 GMT
Author: bodewig
Date: Tue Oct 14 09:05:17 2008
New Revision: 704571

URL: http://svn.apache.org/viewvc?rev=704571&view=rev
Log:
subclasses of AssertionErrors are caused by test failures, not errors.  PR 45028.

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

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=704571&r1=704570&r2=704571&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Oct 14 09:05:17 2008
@@ -247,6 +247,12 @@
  * MailLogger could cause a NullPointerException.
    Bugzilla Report 44009.
 
+ * <junit> didn't recognize failed assertions as failures if they
+   caused subclasses of AssertionError to be thrown (like
+   org.junit.ComparisonFailure that is thrown when assertEquals
+   fails).
+   Bugzilla Report 45028.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java?rev=704571&r1=704570&r2=704571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
Tue Oct 14 09:05:17 2008
@@ -976,7 +976,7 @@
                     // even in the JUnit 3 adapter.
                     // So we need to help it a bit to retain compatibility for JUnit 3 tests.
                     testListener.addFailure(test, (AssertionFailedError) t);
-                } else if (junit4 && t.getClass().getName().equals("java.lang.AssertionError"))
{
+                } else if (junit4 && isAssertionError(t.getClass())) {
                     // Not strictly necessary but probably desirable.
                     // JUnit 4-specific test GUIs will show just "failures".
                     // But Ant's output shows "failures" vs. "errors".
@@ -1035,7 +1035,7 @@
         while (e.hasMoreElements()) {
             Throwable t = ((TestFailure) e.nextElement()).thrownException();
             if (t instanceof AssertionFailedError
-                || t.getClass().getName().equals("java.lang.AssertionError")) {
+                || isAssertionError(t.getClass())) {
                 failures++;
             } else {
                 errors++;
@@ -1044,4 +1044,14 @@
         return new int[] {failures, errors};
     }
 
+    private static boolean isAssertionError(Class clazz) {
+        while (clazz != null) {
+            if (clazz.getName().equals("java.lang.AssertionError")) {
+                return true;
+            }
+            clazz = clazz.getSuperclass();
+        }
+        return false;
+    }
+
 } // JUnitTestRunner



Mime
View raw message