org.apache.ant.antunit
Class AntUnit

java.lang.Object
  extended by Task
      extended by org.apache.ant.antunit.AntUnit

public class AntUnit
extends Task

Run every target whose name starts with "test" in a set of build files.

Run the "setUp" target before each of them if present, same for "tearDown" after each "test*" target (targets named just "test" are ignored). If a target throws an AssertionFailedException, the test has failed; any other exception is considered an error (although BuildException will be scanned recursively for nested AssertionFailedExceptions).


Nested Class Summary
static class AntUnit.Reference
           
static class AntUnit.ReferenceSet
          Defines a collection of inherited references, with an optional nested Mapper that maps them to new reference IDs in the target project.
 
Field Summary
static java.lang.String ERROR_NO_TESTS
          Message if no tests have been specified.
static java.lang.String ERROR_NON_FILES
          Message if non-File resources have been specified.
static java.lang.String ERROR_TESTS_FAILED
          Message to print if an error or failure occured.
 
Constructor Summary
AntUnit()
           
 
Method Summary
 void add(ResourceCollection rc)
          Add build files to run as tests.
 void addPropertySet(PropertySet ps)
          Add a PropertySet.
 void addReference(AntUnit.Reference reference)
          Add an inherited reference
 AntUnit.ReferenceSet createReferenceSet()
          Add a set of inherited references.
 void execute()
          Execute the tests.
 void handleErrorFlush(java.lang.String errorOutputToFlush)
          Redirect error flush to new project instance.
 void handleErrorOutput(java.lang.String errorOutputToHandle)
          Redirect error output to new project instance.
 void handleFlush(java.lang.String toFlush)
          Redirect flush to new project instance.
 int handleInput(byte[] buffer, int offset, int length)
          Redirect input to new project instance.
 void handleOutput(java.lang.String outputToHandle)
          Redirect output to new project instance.
 void setErrorProperty(java.lang.String s)
          Set the name of a property to set if an error or failure occurs.
 void setFailOnError(boolean failOnError)
          Set whether to stop testing if an error or failure occurs?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_TESTS_FAILED

public static final java.lang.String ERROR_TESTS_FAILED
Message to print if an error or failure occured.

See Also:
Constant Field Values

ERROR_NO_TESTS

public static final java.lang.String ERROR_NO_TESTS
Message if no tests have been specified.

See Also:
Constant Field Values

ERROR_NON_FILES

public static final java.lang.String ERROR_NON_FILES
Message if non-File resources have been specified.

See Also:
Constant Field Values
Constructor Detail

AntUnit

public AntUnit()
Method Detail

add

public void add(ResourceCollection rc)
Add build files to run as tests.

Parameters:
rc - the ResourceCollection to add.

addPropertySet

public void addPropertySet(PropertySet ps)
Add a PropertySet.

Parameters:
ps - the PropertySet to add.

createReferenceSet

public AntUnit.ReferenceSet createReferenceSet()
Add a set of inherited references.


addReference

public void addReference(AntUnit.Reference reference)
Add an inherited reference


setErrorProperty

public void setErrorProperty(java.lang.String s)
Set the name of a property to set if an error or failure occurs.

Parameters:
s - the name of the error property.

setFailOnError

public void setFailOnError(boolean failOnError)
Set whether to stop testing if an error or failure occurs?

Parameters:
failOnError - default true

execute

public void execute()
Execute the tests.


handleOutput

public void handleOutput(java.lang.String outputToHandle)
Redirect output to new project instance.

Parameters:
outputToHandle - the output to handle.

handleInput

public int handleInput(byte[] buffer,
                       int offset,
                       int length)
                throws java.io.IOException
Redirect input to new project instance.

Parameters:
buffer - the buffer containing the input.
offset - the offset into buffer.
length - the length of the data.
Throws:
java.io.IOException

handleFlush

public void handleFlush(java.lang.String toFlush)
Redirect flush to new project instance.

Parameters:
toFlush - the output String to flush.

handleErrorOutput

public void handleErrorOutput(java.lang.String errorOutputToHandle)
Redirect error output to new project instance.

Parameters:
errorOutputToHandle - the error output to handle.

handleErrorFlush

public void handleErrorFlush(java.lang.String errorOutputToFlush)
Redirect error flush to new project instance.

Parameters:
errorOutputToFlush - the error output to flush.