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
This commit is contained in:
Stefan Bodewig 2006-08-26 18:48:30 +00:00
parent f0fd5ca05a
commit ebe4ec976a
1 changed files with 17 additions and 1 deletions

View File

@ -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" : ""));
}
}
}