ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r420102 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit: JUnitTask.java JUnitTaskMirrorImpl.java
Date Sat, 08 Jul 2006 12:30:43 GMT
Author: jkf
Date: Sat Jul  8 05:30:43 2006
New Revision: 420102

URL: http://svn.apache.org/viewvc?rev=420102&view=rev
Log:
Give better information in case of timeout for JUnit test,as requested in Bug 39946.

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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=420102&r1=420101&r2=420102&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Sat
Jul  8 05:30:43 2006
@@ -1336,7 +1336,7 @@
      */
 
     private void logTimeout(FormatterElement[] feArray, JUnitTest test) {
-        logVmExit(feArray, test, "Timeout occurred");
+        logVmExit(feArray, test, "Timeout occurred.");
     }
 
     /**
@@ -1347,7 +1347,7 @@
      * @since Ant 1.7
      */
     private void logVmCrash(FormatterElement[] feArray, JUnitTest test) {
-        logVmExit(feArray, test, "forked Java VM exited abnormally");
+        logVmExit(feArray, test, "Forked Java VM exited abnormally.");
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java?rev=420102&r1=420101&r2=420102&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java
Sat Jul  8 05:30:43 2006
@@ -19,7 +19,7 @@
 
 import java.io.OutputStream;
 import junit.framework.AssertionFailedError;
-import junit.framework.Test;
+import junit.framework.TestCase;
 import junit.framework.TestResult;
 import org.apache.tools.ant.AntClassLoader;
 
@@ -31,28 +31,22 @@
  * @since 1.7
  */
 public final class JUnitTaskMirrorImpl implements JUnitTaskMirror {
-    
+
     private final JUnitTask task;
-    
+
     public JUnitTaskMirrorImpl(JUnitTask task) {
         this.task = task;
     }
-    
+
     public void addVmExit(JUnitTest test, JUnitTaskMirror.JUnitResultFormatterMirror _formatter,
             OutputStream out, final String message) {
         JUnitResultFormatter formatter = (JUnitResultFormatter) _formatter;
         formatter.setOutput(out);
         formatter.startTestSuite(test);
-        
         //the trick to integrating test output to the formatter, is to
         //create a special test class that asserts an error
         //and tell the formatter that it raised.
-        Test t = new Test() {
-            public int countTestCases() { return 1; }
-            public void run(TestResult r) {
-                throw new AssertionFailedError(message);
-            }
-        };
+        TestCase t = new VmExitErrorTest(message, test);
         formatter.startTest(t);
         formatter.addError(t, new AssertionFailedError(message));
         formatter.endTestSuite(test);
@@ -68,5 +62,31 @@
     public JUnitTaskMirror.SummaryJUnitResultFormatterMirror newSummaryJUnitResultFormatter()
{
         return new SummaryJUnitResultFormatter();
     }
-    
+
+    static class VmExitErrorTest extends TestCase {
+
+        private String message;
+        private JUnitTest test;
+
+        VmExitErrorTest(String aMessage, JUnitTest anOriginalTest) {
+            message = aMessage;
+            test = anOriginalTest;
+        }
+
+        public int countTestCases() {
+            return 1;
+        }
+
+        public void run(TestResult r) {
+            throw new AssertionFailedError(message);
+        }
+
+        public String getName() {
+            return test.getName();
+        }
+
+        public String toString() {
+            return test.getName();
+        }
+    }
 }



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


Mime
View raw message