From ebe4ec976aa9c9e5f9f2a3cbe5bef70f505acbe2 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Sat, 26 Aug 2006 18:48:30 +0000 Subject: [PATCH] Add an errorProperty attribute, document failOnError attribute git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/antunit/trunk@437204 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/ant/antunit/AntUnit.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/ant/antunit/AntUnit.java b/src/main/org/apache/ant/antunit/AntUnit.java index cf2ceff..4ceb6e4 100644 --- a/src/main/org/apache/ant/antunit/AntUnit.java +++ b/src/main/org/apache/ant/antunit/AntUnit.java @@ -97,6 +97,10 @@ public class AntUnit extends Task { * stop testing if an error or failure occurs? */ private boolean failOnError=true; + /** + * Name of a property to set in case of an error. + */ + private String errorProperty = null; /** * Message to print if an error or failure occured. @@ -136,6 +140,13 @@ public class AntUnit extends Task { propertySets.add(ps); } + /** + * Sets the name of a property to set if an error or failure occurs. + */ + public void setErrorProperty(String s) { + errorProperty = s; + } + /** * stop testing if an error or failure occurs? */ @@ -148,11 +159,16 @@ public class AntUnit extends Task { throw new BuildException(ERROR_NO_TESTS); } doResourceCollection(buildFiles); - if (failOnError && (failures > 0 || errors > 0)) { + if (failures > 0 || errors > 0) { + if (errorProperty != null) { + getProject().setNewProperty(errorProperty, "true"); + } + if (failOnError) { throw new BuildException(ERROR_TESTS_FAILED + failures + " failure" + (failures != 1 ? "s" : "") + " and " + errors + " error" + (errors != 1 ? "s" : "")); + } } }