org.apache.tools.ant.taskdefs.optional.junit

Class JUnitTest

public class JUnitTest extends BaseTest implements Cloneable

Run a single JUnit test.

The JUnit test is actually run by JUnitTestRunner. So read the doc comments for that class :)

Since: Ant 1.2

See Also: JUnitTask JUnitTestRunner

Constructor Summary
JUnitTest()
No arg constructor.
JUnitTest(String name)
Constructor with name.
JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, boolean filtertrace)
Constructor with options.
Method Summary
Objectclone()
longerrorCount()
Get the number of errors.
longfailureCount()
Get the number of failures.
FormatterElement[]getFormatters()
Get the formatters set for this test.
StringgetName()
Get the name of the test class.
StringgetOutfile()
Get the name of the output file
PropertiesgetProperties()
Get the properties used in the test.
longgetRunTime()
Get the run time.
longrunCount()
Get the number of runs.
voidsetCounts(long runs, long failures, long errors)
Set the number of runs, failures and errors.
voidsetName(String value)
Set the name of the test class.
voidsetOutfile(String value)
Set the name of the output file.
voidsetProperties(Hashtable p)
Set the properties to be used in the test.
voidsetRunTime(long runTime)
Set the runtime.
booleanshouldRun(Project p)
Check if this test should run based on the if and unless attributes.

Constructor Detail

JUnitTest

public JUnitTest()
No arg constructor.

JUnitTest

public JUnitTest(String name)
Constructor with name.

Parameters: name the name of the test.

JUnitTest

public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, boolean filtertrace)
Constructor with options.

Parameters: name the name of the test. haltOnError if true halt the tests if there is an error. haltOnFailure if true halt the tests if there is a failure. filtertrace if true filter stack traces.

Method Detail

clone

public Object clone()

Returns: a clone of this test.

Since: Ant 1.5

errorCount

public long errorCount()
Get the number of errors.

Returns: the number of errors.

failureCount

public long failureCount()
Get the number of failures.

Returns: the number of failures.

getFormatters

public FormatterElement[] getFormatters()
Get the formatters set for this test.

Returns: the formatters as an array.

getName

public String getName()
Get the name of the test class.

Returns: the name of the test.

getOutfile

public String getOutfile()
Get the name of the output file

Returns: the name of the output file.

getProperties

public Properties getProperties()
Get the properties used in the test.

Returns: the properties.

getRunTime

public long getRunTime()
Get the run time.

Returns: the run time in milliseconds.

runCount

public long runCount()
Get the number of runs.

Returns: the number of runs.

setCounts

public void setCounts(long runs, long failures, long errors)
Set the number of runs, failures and errors.

Parameters: runs the number of runs. failures the number of failures. errors the number of errors.

setName

public void setName(String value)
Set the name of the test class.

Parameters: value the name to use.

setOutfile

public void setOutfile(String value)
Set the name of the output file.

Parameters: value the name of the output file to use.

setProperties

public void setProperties(Hashtable p)
Set the properties to be used in the test.

Parameters: p the properties. This is a copy of the projects ant properties.

setRunTime

public void setRunTime(long runTime)
Set the runtime.

Parameters: runTime the time in milliseconds.

shouldRun

public boolean shouldRun(Project p)
Check if this test should run based on the if and unless attributes.

Parameters: p the project to use to check if the if and unless properties exist in.

Returns: true if this test or testsuite should be run.