ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r420106 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit: JUnitTask.java JUnitTaskMirrorImpl.java JUnitVersionHelper.java
Date Sat, 08 Jul 2006 13:27:34 GMT
Author: jkf
Date: Sat Jul  8 06:27:33 2006
New Revision: 420106

URL: http://svn.apache.org/viewvc?rev=420106&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
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.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=420106&r1=420105&r2=420106&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 06:27:33 2006
@@ -1336,7 +1336,7 @@
      */
 
     private void logTimeout(FormatterElement[] feArray, JUnitTest test) {
-        logVmExit(feArray, test, "Timeout occurred.");
+        logVmExit(feArray, test, "Timeout occurred. Please note the time in the report does
not reflect the time until the timeout.");
     }
 
     /**
@@ -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. Please note the time
in the report does not reflect the time until the VM exit.");
     }
 
     /**
@@ -1375,38 +1375,28 @@
             for (int i = 0; i < feArray.length; i++) {
                 FormatterElement fe = feArray[i];
                 File outFile = getOutput(fe, test);
-                JUnitTaskMirror.JUnitResultFormatterMirror formatter = 
+                JUnitTaskMirror.JUnitResultFormatterMirror formatter =
                     fe.createFormatter(classLoader);
                 if (outFile != null && formatter != null) {
                     try {
                         OutputStream out = new FileOutputStream(outFile);
-                        addVmExit(test, formatter, out, message);
+                        delegate.addVmExit(test, formatter, out, message);
                     } catch (IOException e) {
                         // ignore
                     }
                 }
             }
             if (summary) {
-                JUnitTaskMirror.SummaryJUnitResultFormatterMirror f = 
+                JUnitTaskMirror.SummaryJUnitResultFormatterMirror f =
                     delegate.newSummaryJUnitResultFormatter();
                 f.setWithOutAndErr("withoutanderr".equalsIgnoreCase(summaryValue));
-                addVmExit(test, f, getDefaultOutput(), message);
+                delegate.addVmExit(test, f, getDefaultOutput(), message);
             }
         } finally {
             if (classLoader != null) {
                 classLoader.resetThreadContextLoader();
             }
         }
-    }
-
-    /**
-     * Adds the actual error message to the formatter.
-     * Only used from the logVmExit method.
-     * @since Ant 1.7
-     */
-    private void addVmExit(JUnitTest test, JUnitTaskMirror.JUnitResultFormatterMirror formatter,
-                           OutputStream out, final String message) {
-        delegate.addVmExit(test, formatter, out, message);
     }
 
     /**

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=420106&r1=420105&r2=420106&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 06:27:33 2006
@@ -38,9 +38,9 @@
         this.task = task;
     }
 
-    public void addVmExit(JUnitTest test, JUnitTaskMirror.JUnitResultFormatterMirror _formatter,
+    public void addVmExit(JUnitTest test, JUnitTaskMirror.JUnitResultFormatterMirror aFormatter,
             OutputStream out, final String message) {
-        JUnitResultFormatter formatter = (JUnitResultFormatter) _formatter;
+        JUnitResultFormatter formatter = (JUnitResultFormatter) aFormatter;
         formatter.setOutput(out);
         formatter.startTestSuite(test);
         //the trick to integrating test output to the formatter, is to
@@ -81,7 +81,7 @@
             throw new AssertionFailedError(message);
         }
 
-        public String getName() {
+        String getClassName() {
             return test.getName();
         }
 

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=420106&r1=420105&r2=420106&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
Sat Jul  8 06:27:33 2006
@@ -24,7 +24,6 @@
 /**
  * Work around for some changes to the public JUnit API between
  * different JUnit releases.
- *
  */
 public class JUnitVersionHelper {
 
@@ -99,6 +98,9 @@
      */
     static String getTestCaseClassName(Test test) {
         String className = test.getClass().getName();
+        if (test instanceof JUnitTaskMirrorImpl.VmExitErrorTest) {
+            className = ((JUnitTaskMirrorImpl.VmExitErrorTest) test).getClassName();
+        } else
         if (className.equals("junit.framework.JUnit4TestCaseFacade")) {
             // JUnit 4 wraps solo tests this way. We can extract
             // the original test name with a little hack.



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


Mime
View raw message