ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r441848 - in /ant/antlibs/antunit/trunk/src: main/org/apache/ant/antunit/listener/ tests/junit/org/apache/ant/antunit/
Date Sat, 09 Sep 2006 19:44:58 GMT
Author: bodewig
Date: Sat Sep  9 12:44:57 2006
New Revision: 441848

URL: http://svn.apache.org/viewvc?view=rev&rev=441848
Log:
Add some useful information to the reports

Modified:
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/PlainAntUnitListener.java
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java
    ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/PlainAntUnitListener.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/PlainAntUnitListener.java?view=diff&rev=441848&r1=441847&r2=441848
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/PlainAntUnitListener.java
(original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/PlainAntUnitListener.java
Sat Sep  9 12:44:57 2006
@@ -28,6 +28,7 @@
 import org.apache.ant.antunit.AssertionFailedException;
 
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Project;
 
 /**
@@ -101,24 +102,37 @@
         }
     }
 
+    public void startTest(String target) {
+        super.startTest(target);
+        wri.print("Target: " + target + " ");
+    }
+
     public void endTest(String target) {
-        wri.print("Target: " + target);
         double seconds = (System.currentTimeMillis() - testStart) / 1000.0;
-        wri.println(" took " + nf.format(seconds) + " sec");
+        wri.println("took " + nf.format(seconds) + " sec");
     }
 
     public void addFailure(String target, AssertionFailedException ae) {
         super.addFailure(target, ae);
-        formatError("\tFAILED", ae);
+        formatError(" FAILED", ae);
     }
     public void addError(String target, Throwable ae) {
         super.addError(target, ae);
-        formatError("\tCaused an ERROR", ae);
+        formatError(" caused an ERROR", ae);
     }
 
     private void formatError(String type, Throwable t) {
         wri.println(type);
-        wri.println(t.getMessage());
+        Location l = getLocation(t);
+        if (l.getLineNumber() != 0) {
+            wri.print("\tat line " + l.getLineNumber());
+            if (l.getColumnNumber() != 0) {
+                wri.print(", column " + l.getColumnNumber());
+            }
+            wri.println();
+        }
+        wri.println("\tMessage: " + t.getMessage());
+        wri.print("\t");
     }
 
 }

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java?view=diff&rev=441848&r1=441847&r2=441848
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java
(original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java
Sat Sep  9 12:44:57 2006
@@ -31,6 +31,7 @@
 import org.apache.ant.antunit.AssertionFailedException;
 
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.util.DateUtils;
 import org.apache.tools.ant.util.DOMElementWriter;
@@ -157,6 +158,15 @@
     private void formatError(String type, Throwable t) {
         try {
             Element e = DOMUtils.createChildElement(currentTest, type);
+            Location l = getLocation(t);
+            if (l.getLineNumber() != 0) {
+                e.setAttribute(XMLConstants.ATTR_LINE,
+                               String.valueOf(l.getLineNumber()));
+            }
+            if (l.getColumnNumber() != 0) {
+                e.setAttribute(XMLConstants.ATTR_COLUMN,
+                               String.valueOf(l.getColumnNumber()));
+            }
             String message = t.getMessage();
             if (message != null && message.length() > 0) {
                 e.setAttribute(XMLConstants.ATTR_MESSAGE, t.getMessage());

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java?view=diff&rev=441848&r1=441847&r2=441848
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java (original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java Sat
Sep  9 12:44:57 2006
@@ -92,6 +92,12 @@
     /** id attribute */
     String ATTR_ID = "id";
 
+    /** linenumber attribute */
+    String ATTR_LINE = "linenumber";
+
+    /** columnnumber attribute */
+    String ATTR_COLUMN = "columnnumber";
+
     /**
      * timestamp of test cases
      */

Modified: ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java?view=diff&rev=441848&r1=441847&r2=441848
==============================================================================
--- ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java (original)
+++ ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java Sat
Sep  9 12:44:57 2006
@@ -53,7 +53,7 @@
         assertTrue("test5", log.indexOf("test5", index) > -1);
         assertTrue("testLogCaptureActive",
                    log.indexOf("testLogCaptureActive", index) > -1);
-        int index2 = log.indexOf("Caused an ERROR", index);
+        int index2 = log.indexOf("caused an ERROR", index);
         assertTrue("test5 error", index2 > -1
                    && log.indexOf("test5 exits with error", index2) > -1);
         assertTrue("Only one error", log.indexOf("ERROR", index2 + 11) == -1);



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


Mime
View raw message