You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by st...@apache.org on 2006/06/05 00:34:30 UTC

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

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


re: antunit

Posted by Steve Loughran <st...@apache.org>.
Stefan Bodewig wrote:
> On Mon, 05 Jun 2006, Steve Loughran <st...@apache.org> wrote:
> 
>> what is the release status of Antunit? Is is formally released? 
> 
> No.
> 
> I intend to propose release plans for AntUnit and the .NET Antlib as
> soon as Ant 1.7 is on the way.
> 

ok. I've just started making use of antunit; it is very nice indeed. 
It's trivially easy to turn out tests.

something that output results in the classic junit XML format would be 
nice...

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


Re: 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

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 05 Jun 2006, Steve Loughran <st...@apache.org> wrote:

> what is the release status of Antunit? Is is formally released? 

No.

I intend to propose release plans for AntUnit and the .NET Antlib as
soon as Ant 1.7 is on the way.

Cheers

        Stefan

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


Re: 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

Posted by Steve Loughran <st...@apache.org>.
Dominique Devienne wrote:
>> There is one big change here; a failing antunit test does now actually
>> halt the build. the other one matters less, as it makes the
>> expectedMessage string in <expectFailure> a substring search on the
>> failure message, not a complete match. this is useful if part of the
>> message varies depending upon the target platform
> 
> Is this change linked to the Gump failure? --DD
> 

Probably :)

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


Re: 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

Posted by Dominique Devienne <dd...@gmail.com>.
> There is one big change here; a failing antunit test does now actually
> halt the build. the other one matters less, as it makes the
> expectedMessage string in <expectFailure> a substring search on the
> failure message, not a complete match. this is useful if part of the
> message varies depending upon the target platform

Is this change linked to the Gump failure? --DD

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


Re: 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

Posted by Steve Loughran <st...@apache.org>.
stevel@apache.org wrote:
> 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/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" : ""));
> +        }
>      }



There is one big change here; a failing antunit test does now actually 
halt the build. the other one matters less, as it makes the 
expectedMessage string in <expectFailure> a substring search on the 
failure message, not a complete match. this is useful if part of the 
message varies depending upon the target platform

what is the release status of Antunit? Is is formally released? There is 
no obvious JAR on the web page...

-steve

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