![]()
|
JUnitTask (Apache Ant API)
org.apache.tools.ant.taskdefs.optional.junit
|
Nested Class Summary | |
static class |
JUnitTask.SummaryAttribute
Print summary enumeration values. |
Field Summary |
Fields inherited from class org.apache.tools.ant.Task |
description, location, target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
project |
Constructor Summary | |
JUnitTask()
Creates a new JUnitRunner and enables fork of a new Java VM. |
Method Summary | |
protected void |
addClasspathEntry(java.lang.String resource)
Search for the given resource and add the directory or archive that contains it to the classpath. |
void |
addEnv(Environment.Variable var)
Adds an environment variable; used when forking. |
void |
addFormatter(FormatterElement fe)
Add a new formatter to all tests of this task. |
void |
addSysproperty(Environment.Variable sysp)
Adds a system property that tests can access. |
void |
addTest(JUnitTest test)
Add a new single testcase. |
protected java.util.Enumeration |
allTests()
|
BatchTest |
createBatchTest()
Adds a set of tests based on pattern matching. |
Path |
createClasspath()
Adds path to classpath used for tests. |
Commandline.Argument |
createJvmarg()
Adds a JVM argument; ignored if not forking. |
protected ExecuteWatchdog |
createWatchdog()
|
void |
execute()
Runs the testcase. |
protected void |
execute(JUnitTest arg)
Run the tests. |
protected java.io.OutputStream |
getDefaultOutput()
Get the default output for a formatter. |
protected java.util.Enumeration |
getIndividualTests()
Merge all individual tests from the batchtest with all individual tests and return an enumeration over all JUnitTest. |
protected java.io.File |
getOutput(FormatterElement fe,
JUnitTest test)
If the formatter sends output to a file, return that file. |
protected void |
handleErrorOutput(java.lang.String line)
Pass output sent to System.err to the TestRunner so it can collect ot for the formatters. |
protected void |
handleOutput(java.lang.String line)
Pass output sent to System.out to the TestRunner so it can collect ot for the formatters. |
void |
init()
Adds the jars or directories containing Ant, this task and JUnit to the classpath - this should make the forked JVM work without having to specify them directly. |
void |
setDir(java.io.File dir)
The directory to invoke the VM in. |
void |
setErrorProperty(java.lang.String propertyName)
Property to set to "true" if there is a error in a test. |
void |
setFailureProperty(java.lang.String propertyName)
Property to set to "true" if there is a failure in a test. |
void |
setFiltertrace(boolean value)
If true, smartly filter the stack frames of JUnit errors and failures before reporting them. |
void |
setFork(boolean value)
If true, JVM should be forked for each test. |
void |
setHaltonerror(boolean value)
If true, stop the build process when there is an error in a test. |
void |
setHaltonfailure(boolean value)
If true, stop the build process if a test fails (errors are considered failures as well). |
void |
setIncludeantruntime(boolean b)
If true, include ant.jar, optional.jar and junit.jar in the forked VM. |
void |
setJvm(java.lang.String value)
The command used to invoke the Java Virtual Machine, default is 'java'. |
void |
setMaxmemory(java.lang.String max)
Set the maximum memory to be used by all forked JVMs. |
void |
setNewenvironment(boolean newenv)
If true, use a new environment when forked. |
void |
setPrintsummary(JUnitTask.SummaryAttribute value)
If true, print one-line statistics for each test, or "withOutAndErr" to also show standard output and error. |
void |
setShowOutput(boolean showOutput)
If true, send any output generated by tests to Ant's logging system as well as to the formatters. |
void |
setTimeout(java.lang.Integer value)
Set the timeout value (in milliseconds). |
Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
getProject, setProject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JUnitTask() throws java.lang.Exception
Method Detail |
public void setFiltertrace(boolean value)
This property is applied on all BatchTest (batchtest) and JUnitTest (test) however it can possibly be overridden by their own properties.
value
- false if it should not filter, otherwise
truepublic void setHaltonerror(boolean value)
value
- true if it should halt, otherwise
falsepublic void setErrorProperty(java.lang.String propertyName)
This property is applied on all BatchTest (batchtest) and JUnitTest (test), however, it can possibly be overriden by their own properties.
propertyName
- the name of the property to set in the
event of an error.public void setHaltonfailure(boolean value)
value
- true if it should halt, otherwise
falsepublic void setFailureProperty(java.lang.String propertyName)
This property is applied on all BatchTest (batchtest) and JUnitTest (test), however, it can possibly be overriden by their own properties.
propertyName
- the name of the property to set in the
event of an failure.public void setFork(boolean value)
It avoids interference between testcases and possibly avoids hanging the build. this property is applied on all BatchTest (batchtest) and JUnitTest (test) however it can possibly be overridden by their own properties.
value
- true if a JVM should be forked, otherwise
falsesetTimeout(java.lang.Integer)
public void setPrintsummary(JUnitTask.SummaryAttribute value)
value
- true to print a summary,
withOutAndErr to include the test's output as
well, false otherwise.SummaryJUnitResultFormatter
public void setTimeout(java.lang.Integer value)
If the test is running for more than this value, the test will be canceled. (works only when in 'fork' mode).
value
- the maximum time (in milliseconds) allowed before
declaring the test as 'timed-out'setFork(boolean)
public void setMaxmemory(java.lang.String max)
max
- the value as defined by -mx or -Xmx
in the java command line options.public void setJvm(java.lang.String value)
value
- the new VM to use instead of javasetFork(boolean)
public Commandline.Argument createJvmarg()
setFork(boolean)
public void setDir(java.io.File dir)
dir
- the directory to invoke the JVM from.setFork(boolean)
public void addSysproperty(Environment.Variable sysp)
public Path createClasspath()
public void addEnv(Environment.Variable var)
Will be ignored if we are not forking a new VM.
public void setNewenvironment(boolean newenv)
Will be ignored if we are not forking a new VM.
public void addTest(JUnitTest test)
test
- a new single testcaseJUnitTest
public BatchTest createBatchTest()
BatchTest
public void addFormatter(FormatterElement fe)
public void setIncludeantruntime(boolean b)
public void setShowOutput(boolean showOutput)
Output will always be passed to the formatters and not by shown by default. This option should for example be set for tests that are interactive and prompt the user to do something.
public void init()
public void execute() throws BuildException
BuildException
- if something goes wrong with the buildprotected void execute(JUnitTest arg) throws BuildException
protected void handleOutput(java.lang.String line)
handleOutput
in class Task
line
- The line of output to log. Should not be null
.protected void handleErrorOutput(java.lang.String line)
handleErrorOutput
in class Task
line
- The error line to log. Should not be null
.protected ExecuteWatchdog createWatchdog() throws BuildException
BuildException
protected java.io.OutputStream getDefaultOutput()
protected java.util.Enumeration getIndividualTests()
protected java.util.Enumeration allTests()
protected java.io.File getOutput(FormatterElement fe, JUnitTest test)
protected void addClasspathEntry(java.lang.String resource)
Doesn't work for archives in JDK 1.1 as the URL returned by getResource doesn't contain the name of the archive.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |