org.apache.tools.ant.taskdefs.optional.junit
public class JUnitTestRunner extends Object implements TestListener
This TestRunner expects a name of a TestCase class as its argument. If this class provides a static suite() method it will be called and the resulting Test will be run. So, the signature should be
public static junit.framework.Test suite()
If no such method exists, all public methods starting with "test" and taking no argument will be run.
Summary output is generated at the end.
Since: Ant 1.2
Field Summary | |
---|---|
static int | ERRORS
An error occurred. |
static int | FAILURES
Some tests failed. |
static String | IGNORED_FILE_NAME
Used in formatter arguments as a placeholder for the basename
of the output file (which gets replaced by a test specific
output file name later).
|
static int | SUCCESS
No problems with this test. |
Constructor Summary | |
---|---|
JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure)
Constructor for fork=true or when the user hasn't specified a
classpath. | |
JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput)
Constructor for fork=true or when the user hasn't specified a
classpath. | |
JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, ClassLoader loader)
Constructor to use when the user has specified a classpath. | |
JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, ClassLoader loader)
Constructor to use when the user has specified a classpath. |
Method Summary | |
---|---|
void | addError(Test test, Throwable t)
Interface TestListener.
|
void | addFailure(Test test, Throwable t)
Interface TestListener for JUnit <= 3.4.
|
void | addFailure(Test test, AssertionFailedError t)
Interface TestListener for JUnit > 3.4.
|
void | addFormatter(JUnitResultFormatter f) |
void | endTest(Test test)
Interface TestListener.
|
static String | filterStack(String stack)
Filters stack frames from internal JUnit and Ant classes |
static String | getFilteredTrace(Throwable t)
Returns a filtered stack trace.
|
int | getRetCode()
Returns what System.exit() would return in the standalone version.
|
protected void | handleErrorFlush(String output) |
protected void | handleErrorOutput(String output) |
protected void | handleFlush(String output) |
protected int | handleInput(byte[] buffer, int offset, int length) |
protected void | handleOutput(String output) |
static void | main(String[] args)
Entry point for standalone (forked) mode.
|
void | run() |
void | setPermissions(Permissions permissions)
Permissions for the test run. |
void | startTest(Test t)
Interface TestListener.
|
Since: Ant 1.6.3
An error occurred while running the test.
A Test failed.
A Test failed.
A Test is finished.
Returns: 2 if errors occurred, 1 if tests failed else 0.
Since: Ant 1.6
See Also: (byte[], int, int)
key | description | default value |
---|---|---|
haltOnError | halt test on errors? | false |
haltOnFailure | halt test on failures? | false |
formatter | A JUnitResultFormatter given as classname,filename. If filename is ommitted, System.out is assumed. | none |
showoutput | send output to System.err/.out as well as to the formatters? | false |
Parameters: permissions
Since: Ant 1.6
A new Test is started.