net.sf.antcontrib.logic
Class Assert
Task
net.sf.antcontrib.logic.Assert
- TaskContainer
public class Assert
extends Task
implements TaskContainer
Based on the Sequential task.
Similar to Java's 'assert' keyword, verifies that a given property has a
given value. Throws a BuildException if the property value is not as expected
or the property does not exist.
Also like Java's 'assert' keyword, the Assert task must be 'turned on' using
the property "ant.enable.asserts". If not set, or is set to false, the Assert task
works exactly like the Sequential task.
Can hold other tasks including Assert.
Attributes:
- name - the name of a property. Required.
- exists - boolean, if true, throws BuildException if the property does not
exist. Optional, default is true.
- value - the expected value of a property. Implies 'exists'. Throws
BuildException if the actual value is not the same as this value. Optional.
- execute - boolean, if true, execute any contained tasks. Optional, default
is true. Can also be set globally by setting the value of "assert.execute"
to true or false. The local setting overrides the global setting.
- Dale Anson, danson@germane-software.com
void | addBool(BooleanConditionTask boolTask)
|
void | addTask(Task task) - Add a nested task to execute.
|
void | execute() - Execute this task and all nested Tasks.
|
static void | main(String[] args)
|
void | maybeConfigure() - Override
maybeConfigure in a way that leaves the nested tasks
unconfigured until they get executed.
|
static int | runTests()
|
void | setExecute(String execute) - Ant boolean, if true, execute any contained tasks.
|
void | setExists(String exists) - Set the 'exists' attribute.
|
void | setFailonerror(String fail) - Ant boolean, stop the build process if the assertion fails.
|
void | setMessage(String msg)
|
void | setName(String name) - Set the name of the property to test.
|
void | setValue(String value) - Set the expected value of the property.
|
addTask
public void addTask(Task task)
Add a nested task to execute.
task
- Nested task to execute.
execute
public void execute()
throws BuildException
Execute this task and all nested Tasks.
main
public static void main(String[] args)
maybeConfigure
public void maybeConfigure()
throws BuildException
Override maybeConfigure
in a way that leaves the nested tasks
unconfigured until they get executed.
runTests
public static int runTests()
setExecute
public void setExecute(String execute)
Ant boolean, if true, execute any contained tasks. Optional, default
is true. Can also be set globally by setting the value of "assert.execute"
to true or false. The local setting overrides the global setting.
execute
- Ant boolean, whether to execute contained tasks.
setExists
public void setExists(String exists)
Set the 'exists' attribute. If true, throws BuildException if the property does not
exist. Optional, default is true.
exists
- Ant boolean, whether the value must exist.
setFailonerror
public void setFailonerror(String fail)
Ant boolean, stop the build process if the assertion fails. Defaults to
true. Setting this to false is contrary to the intented use of
assertions, but may be useful in certain situations.
fail
- Ant boolean, whether to stop the build on assertion error.
setMessage
public void setMessage(String msg)
setName
public void setName(String name)
Set the name of the property to test. Required.
name
- the name of the property to test.
setValue
public void setValue(String value)
Set the expected value of the property. Implies 'exists'. Throws
BuildException if the actual value is not the same as this value. Optional.
value
- the expected value of the property.