| java.lang.Object org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner
JUnitTestRunner | public class JUnitTestRunner implements TestListener,JUnitTaskMirror.JUnitTestRunnerMirror(Code) | | Simple Testrunner for JUnit that runs all tests of a testsuite.
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 | |
public | JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure) Constructor for fork=true or when the user hasn't specified a
classpath. | public | JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput) Constructor for fork=true or when the user hasn't specified a
classpath. | public | 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. | public | JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, ClassLoader loader) Constructor to use when the user has specified a classpath. | public | JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, ClassLoader loader) Constructor to use when the user has specified a classpath. | public | 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. |
Method Summary | |
public void | addError(Test test, Throwable t) Interface TestListener. | public void | addFailure(Test test, Throwable t) Interface TestListener for JUnit <= 3.4. | public void | addFailure(Test test, AssertionFailedError t) Interface TestListener for JUnit > 3.4. | public void | addFormatter(JUnitResultFormatter f) Add a formatter. | public void | addFormatter(JUnitTaskMirror.JUnitResultFormatterMirror f) . | public void | endTest(Test test) Interface TestListener. | public static String | filterStack(String stack) Filters stack frames from internal JUnit and Ant classes
Parameters: stack - the stack trace to filter. | public static String | getFilteredTrace(Throwable t) Returns a filtered stack trace.
This is ripped out of junit.runner.BaseTestRunner.
Parameters: t - the exception to filter. | public int | getRetCode() Returns what System.exit() would return in the standalone version. | public void | handleErrorFlush(String output) . | public void | handleErrorOutput(String output) . | public void | handleFlush(String output) . | public int | handleInput(byte[] buffer, int offset, int length) Handle input.
Parameters: buffer - not used. Parameters: offset - not used. Parameters: length - not used. | public void | handleOutput(String output) Handle a string destined for standard output. | public static void | main(String[] args) Entry point for standalone (forked) mode.
Parameters: testcaseclassname plus parameters in the format
key=value, none of which is required.
key | description | default value |
haltOnError | halt test on
errors? | false |
haltOnFailure | halt test on
failures? | false |
formatter | A JUnitResultFormatter given as
classname,filename. | public void | run() Run the test. | public void | setPermissions(Permissions permissions) Permissions for the test run. | public void | startTest(Test t) Interface TestListener. |
JUnitTestRunner | public JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure)(Code) | | Constructor for fork=true or when the user hasn't specified a
classpath.
Parameters: test - the test to run. Parameters: haltOnError - whether to stop the run if an error is found. Parameters: filtertrace - whether to filter junit.*.* stack frames out of exceptions Parameters: haltOnFailure - whether to stop the run if failure is found. |
JUnitTestRunner | public JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput)(Code) | | Constructor for fork=true or when the user hasn't specified a
classpath.
Parameters: test - the test to run. Parameters: haltOnError - whether to stop the run if an error is found. Parameters: filtertrace - whether to filter junit.*.* stack frames out of exceptions Parameters: haltOnFailure - whether to stop the run if failure is found. Parameters: showOutput - whether to send output to System.out/.err as well as formatters. |
JUnitTestRunner | public JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, boolean logTestListenerEvents)(Code) | | Constructor for fork=true or when the user hasn't specified a
classpath.
Parameters: test - the test to run. Parameters: haltOnError - whether to stop the run if an error is found. Parameters: filtertrace - whether to filter junit.*.* stack frames out of exceptions Parameters: haltOnFailure - whether to stop the run if failure is found. Parameters: showOutput - whether to send output to System.out/.err as well as formatters. Parameters: logTestListenerEvents - whether to print TestListener events. since: Ant 1.7 |
JUnitTestRunner | public JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, ClassLoader loader)(Code) | | Constructor to use when the user has specified a classpath.
Parameters: test - the test to run. Parameters: haltOnError - whether to stop the run if an error is found. Parameters: filtertrace - whether to filter junit.*.* stack frames out of exceptions Parameters: haltOnFailure - whether to stop the run if failure is found. Parameters: loader - the classloader to use running the test. |
JUnitTestRunner | public JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, ClassLoader loader)(Code) | | Constructor to use when the user has specified a classpath.
Parameters: test - the test to run. Parameters: haltOnError - whether to stop the run if an error is found. Parameters: filtertrace - whether to filter junit.*.* stack frames out of exceptions Parameters: haltOnFailure - whether to stop the run if failure is found. Parameters: showOutput - whether to send output to System.out/.err as well as formatters. Parameters: loader - the classloader to use running the test. |
JUnitTestRunner | public JUnitTestRunner(JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, boolean logTestListenerEvents, ClassLoader loader)(Code) | | Constructor to use when the user has specified a classpath.
Parameters: test - the test to run. Parameters: haltOnError - whether to stop the run if an error is found. Parameters: filtertrace - whether to filter junit.*.* stack frames out of exceptions Parameters: haltOnFailure - whether to stop the run if failure is found. Parameters: showOutput - whether to send output to System.out/.err as well as formatters. Parameters: logTestListenerEvents - whether to print TestListener events. Parameters: loader - the classloader to use running the test. since: Ant 1.7 |
addError | public void addError(Test test, Throwable t)(Code) | | Interface TestListener.
An error occurred while running the test.
Parameters: test - the test. Parameters: t - the error thrown by the test. |
addFailure | public void addFailure(Test test, Throwable t)(Code) | | Interface TestListener for JUnit <= 3.4.
A Test failed.
Parameters: test - the test. Parameters: t - the exception thrown by the test. |
addFailure | public void addFailure(Test test, AssertionFailedError t)(Code) | | Interface TestListener for JUnit > 3.4.
A Test failed.
Parameters: test - the test. Parameters: t - the assertion thrown by the test. |
endTest | public void endTest(Test test)(Code) | | Interface TestListener.
A Test is finished.
Parameters: test - the test. |
filterStack | public static String filterStack(String stack)(Code) | | Filters stack frames from internal JUnit and Ant classes
Parameters: stack - the stack trace to filter. the filtered stack. |
getFilteredTrace | public static String getFilteredTrace(Throwable t)(Code) | | Returns a filtered stack trace.
This is ripped out of junit.runner.BaseTestRunner.
Parameters: t - the exception to filter. the filtered stack trace. |
getRetCode | public int getRetCode()(Code) | | Returns what System.exit() would return in the standalone version.
2 if errors occurred, 1 if tests failed else 0. |
handleErrorFlush | public void handleErrorFlush(String output)(Code) | | .
|
handleErrorOutput | public void handleErrorOutput(String output)(Code) | | .
|
handleOutput | public void handleOutput(String output)(Code) | | Handle a string destined for standard output.
Parameters: output - the string to output |
main | public static void main(String[] args) throws IOException(Code) | | Entry point for standalone (forked) mode.
Parameters: testcaseclassname plus parameters in the format
key=value, none of which is required.
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 |
Parameters: args - the command line arguments. throws: IOException - on error. |
run | public void run()(Code) | | Run the test.
|
setPermissions | public void setPermissions(Permissions permissions)(Code) | | Permissions for the test run.
since: Ant 1.6 Parameters: permissions - the permissions to use. |
startTest | public void startTest(Test t)(Code) | | Interface TestListener.
A new Test is started.
Parameters: t - the test. |
|
|
|