org.apache.tools.ant.taskdefs.optional.junit
public class JUnitTestRunner extends Object implements TestListener, JUnitTaskMirror.JUnitTestRunnerMirror
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
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, boolean showOutput, boolean logTestListenerEvents)
Constructor for fork=true or when the user hasn't specified a
classpath. | |
JUnitTestRunner(JUnitTest test, String[] methods, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, boolean logTestListenerEvents)
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. | |
JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, boolean logTestListenerEvents, ClassLoader loader)
Constructor to use when the user has specified a classpath. | |
JUnitTestRunner(JUnitTest test, String[] methods, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, boolean logTestListenerEvents, 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)
Add a formatter. |
void | addFormatter(JUnitTaskMirror.JUnitResultFormatterMirror f) {@inheritDoc }. |
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.
|
void | handleErrorFlush(String output) {@inheritDoc }. |
void | handleErrorOutput(String output) {@inheritDoc }. |
void | handleFlush(String output) {@inheritDoc }. |
int | handleInput(byte[] buffer, int offset, int length)
Handle input. |
void | handleOutput(String output)
Handle a string destined for standard output. |
static void | main(String[] args)
Entry point for standalone (forked) mode.
|
void | run()
Run the test. |
void | setPermissions(Permissions permissions)
Permissions for the test run. |
void | startTest(Test t)
Interface TestListener.
|
Parameters: test the test to run. haltOnError whether to stop the run if an error is found. filtertrace whether to filter junit.*.* stack frames out of exceptions haltOnFailure whether to stop the run if failure is found.
Parameters: test the test to run. haltOnError whether to stop the run if an error is found. filtertrace whether to filter junit.*.* stack frames out of exceptions haltOnFailure whether to stop the run if failure is found. showOutput whether to send output to System.out/.err as well as formatters.
Parameters: test the test to run. haltOnError whether to stop the run if an error is found. filtertrace whether to filter junit.*.* stack frames out of exceptions haltOnFailure whether to stop the run if failure is found. showOutput whether to send output to System.out/.err as well as formatters. logTestListenerEvents whether to print TestListener events.
Since: Ant 1.7
Parameters: test the test to run. methods names of methods of the test to be executed. haltOnError whether to stop the run if an error is found. filtertrace whether to filter junit.*.* stack frames out of exceptions haltOnFailure whether to stop the run if failure is found. showOutput whether to send output to System.out/.err as well as formatters. logTestListenerEvents whether to print TestListener events.
Since: 1.8.2
Parameters: test the test to run. haltOnError whether to stop the run if an error is found. filtertrace whether to filter junit.*.* stack frames out of exceptions haltOnFailure whether to stop the run if failure is found. loader the classloader to use running the test.
Parameters: test the test to run. haltOnError whether to stop the run if an error is found. filtertrace whether to filter junit.*.* stack frames out of exceptions haltOnFailure whether to stop the run if failure is found. showOutput whether to send output to System.out/.err as well as formatters. loader the classloader to use running the test.
Parameters: test the test to run. haltOnError whether to stop the run if an error is found. filtertrace whether to filter junit.*.* stack frames out of exceptions haltOnFailure whether to stop the run if failure is found. showOutput whether to send output to System.out/.err as well as formatters. logTestListenerEvents whether to print TestListener events. loader the classloader to use running the test.
Since: Ant 1.7
Since: 1.8.2
An error occurred while running the test.
Parameters: test the test. t the error thrown by the test.
A Test failed.
Parameters: test the test. t the exception thrown by the test.
A Test failed.
Parameters: test the test. t the assertion thrown by the test.
Parameters: f the formatter to add.
A Test is finished.
Parameters: test the test.
Parameters: stack the stack trace to filter.
Returns: the filtered stack.
Parameters: t the exception to filter.
Returns: the filtered stack trace.
Returns: 2 if errors occurred, 1 if tests failed else 0.
Parameters: buffer not used. offset not used. length not used.
Returns: -1 always.
Throws: IOException never.
Since: Ant 1.6
See Also: (byte[], int, int)
Parameters: output the string to output
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 |
logtestlistenerevents | log TestListener events to System.out. | false |
methods | Comma-separated list of names of individual test methods to execute. | null |
Parameters: args the command line arguments.
Throws: IOException on error.
Parameters: permissions the permissions to use.
Since: Ant 1.6
A new Test is started.
Parameters: t the test.