ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r411613 - in /ant/antlibs/antunit/trunk: docs/expectfailure.html docs/index.html src/main/org/apache/ant/antunit/AntUnit.java src/main/org/apache/ant/antunit/AssertTask.java src/main/org/apache/ant/antunit/ExpectFailureTask.java
Date Sun, 04 Jun 2006 22:34:30 GMT
Author: stevel
Date: Sun Jun  4 15:34:30 2006
New Revision: 411613

URL: http://svn.apache.org/viewvc?rev=411613&view=rev
Log:
1. typos in assertTask
2. ExpectFailure now does a substring check for the expectedMessage, not a simple exact match
3. AntUnit actually fails the build if the tests failed.

Modified:
    ant/antlibs/antunit/trunk/docs/expectfailure.html
    ant/antlibs/antunit/trunk/docs/index.html
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AntUnit.java
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AssertTask.java
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/ExpectFailureTask.java

Modified: ant/antlibs/antunit/trunk/docs/expectfailure.html
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/docs/expectfailure.html?rev=411613&r1=411612&r2=411613&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/docs/expectfailure.html (original)
+++ ant/antlibs/antunit/trunk/docs/expectfailure.html Sun Jun  4 15:34:30 2006
@@ -30,7 +30,9 @@
       </tr>
       <tr>
         <td valign="top">expectedMessage</td>
-        <td valign="top">Used to assert a specific exception message.</td>
+        <td valign="top">Used to assert a specific exception message.
+        The string will be looked for (case-sensitive) in the fault string;
+        </td>
         <td align="center">No.</td>
       </tr>
     </table>
@@ -62,6 +64,6 @@
     </pre>
 
     <hr/>
-      <p align="center">Copyright &copy; 2005 The Apache Software Foundation. All
rights Reserved.</p>
+      <p align="center">Copyright &copy; 2005-2006 The Apache Software Foundation.
All rights Reserved.</p>
   </body>
 </html>

Modified: ant/antlibs/antunit/trunk/docs/index.html
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/docs/index.html?rev=411613&r1=411612&r2=411613&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/docs/index.html (original)
+++ ant/antlibs/antunit/trunk/docs/index.html Sun Jun  4 15:34:30 2006
@@ -94,7 +94,7 @@
     <ul>
       <li><a href="antunit.html">antunit</a> - run unit tests, the
       tests are defined using build files that contain targets which
-      follow a certain namin convention.  This task borrows a lot of
+      follow a certain naming convention.  This task borrows a lot of
       ideas from JUnit 3 and the junit task.</li>
 
       <li><a href="assert.html">assertTrue</a> - asserts a condition

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AntUnit.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AntUnit.java?rev=411613&r1=411612&r2=411613&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AntUnit.java (original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AntUnit.java Sun Jun  4 15:34:30
2006
@@ -55,6 +55,10 @@
 
     private ArrayList listeners = new ArrayList();
 
+    private int failures=0;
+    private int errors=0;
+    private boolean failOnError=true;
+    
     public void add(FileSet fs) {
         filesets.add(fs);
     }
@@ -63,6 +67,10 @@
         listeners.add(al);
     }
 
+    public void setFailOnError(boolean failOnError) {
+        this.failOnError = failOnError;
+    }
+
     public void execute() {
         if (filesets.size() == 0) {
             throw new BuildException("You must specify at least one nested"
@@ -72,6 +80,12 @@
         while (iter.hasNext()) {
             doFileSet((FileSet) iter.next());
         }
+        if (failOnError && (failures > 0 || errors > 0)) {
+            throw new BuildException("Tests failed with "
+                    + failures + " failure" + (failures != 1 ? "s" : "")
+                    + " and "
+                    + errors + " error" + (errors != 1 ? "s" : ""));
+        }
     }
 
     private void doFileSet(FileSet fs) {
@@ -193,6 +207,7 @@
     }
 
     private void fireFail(String targetName, AssertionFailedException ae) {
+        failures++;
         Iterator it = listeners.iterator();
         while (it.hasNext()) {
             AntUnitListener al = (AntUnitListener) it.next();
@@ -201,6 +216,7 @@
     }
 
     private void fireError(String targetName, Throwable t) {
+        errors++;
         Iterator it = listeners.iterator();
         while (it.hasNext()) {
             AntUnitListener al = (AntUnitListener) it.next();

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AssertTask.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AssertTask.java?rev=411613&r1=411612&r2=411613&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AssertTask.java (original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/AssertTask.java Sun Jun  4 15:34:30
2006
@@ -56,8 +56,8 @@
     public void execute() throws BuildException {
         int count = countConditions();
         if (count > 1) {
-            throw new BuildException("You must not specify more tha one "
-                                     + "conditions");
+            throw new BuildException("You must not specify more than one "
+                                     + "condition");
         }
         if (count < 1) {
             throw new BuildException("You must specify a condition");

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/ExpectFailureTask.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/ExpectFailureTask.java?rev=411613&r1=411612&r2=411613&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/ExpectFailureTask.java (original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/ExpectFailureTask.java Sun Jun
 4 15:34:30 2006
@@ -40,7 +40,7 @@
     }
 
     /**
-     * The message to use in the AssertinFailedException if the nested
+     * The message to use in the AssertionFailedException if the nested
      * tasks fail to raise the "correct" exception.
      */
     public void setMessage(String m) {
@@ -53,14 +53,17 @@
             super.execute();
         } catch (BuildException e) {
             thrown = true;
-            if (expectedMessage != null
-                && !expectedMessage.equals(e.getMessage())) {
+            String caughtMessage = e.getMessage();
+            if (expectedMessage != null &&
+                    (caughtMessage == null
+                            || caughtMessage.indexOf(expectedMessage) < 0)) {
                 if (message == null) {
-                    throw new AssertionFailedException("Expected build failure "
-                                                       + "with message '"
-                                                       + expectedMessage
-                                                       + "' but was '"
-                                                       + e.getMessage() + "'");
+                    throw new AssertionFailedException(
+                            "Expected build failure "
+                                    + "with message '"
+                                    + expectedMessage
+                                    + "' but was '"
+                                    + caughtMessage + "'");
                 } else {
                     throw new AssertionFailedException(message);
                 }



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


Mime
View raw message