org.apache.tools.ant.taskdefs.optional.junit
Class JUnitTestRunner
java.lang.Object
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner
- TestListener, JUnitTaskMirror.JUnitTestRunnerMirror
public class JUnitTestRunner
extends java.lang.Object
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.
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, ClassLoader loader) - Constructor to use when the user has 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, 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) - 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, ClassLoader loader) - Constructor to use when the user has specified a classpath.
|
JUnitTestRunner
public JUnitTestRunner(JUnitTest test,
boolean haltOnError,
boolean filtertrace,
boolean haltOnFailure)
Constructor for fork=true or when the user hasn't specified a
classpath.
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 exceptionshaltOnFailure
- whether to stop the run if failure is found.
JUnitTestRunner
public JUnitTestRunner(JUnitTest test,
boolean haltOnError,
boolean filtertrace,
boolean haltOnFailure,
ClassLoader loader)
Constructor to use when the user has specified a classpath.
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 exceptionshaltOnFailure
- whether to stop the run if failure is found.loader
- the classloader to use running the test.
JUnitTestRunner
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.
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 exceptionshaltOnFailure
- whether to stop the run if failure is found.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,
ClassLoader loader)
Constructor to use when the user has specified a classpath.
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 exceptionshaltOnFailure
- 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.
JUnitTestRunner
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.
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 exceptionshaltOnFailure
- 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.
JUnitTestRunner
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.
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 exceptionshaltOnFailure
- 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.
addError
public void addError(Test test,
Throwable t)
Interface TestListener.
An error occurred while running the test.
test
- the test.t
- the error thrown by the test.
addFailure
public void addFailure(Test test,
AssertionFailedError t)
Interface TestListener for JUnit > 3.4.
A Test failed.
test
- the test.t
- the assertion thrown by the test.
addFailure
public void addFailure(Test test,
Throwable t)
Interface TestListener for JUnit <= 3.4.
A Test failed.
test
- the test.t
- the exception thrown by the test.
addFormatter
public void addFormatter(JUnitResultFormatter f)
Add a formatter.
f
- the formatter to add.
endTest
public void endTest(Test test)
Interface TestListener.
A Test is finished.
filterStack
public static String filterStack(String stack)
Filters stack frames from internal JUnit and Ant classes
stack
- the stack trace to filter.
getFilteredTrace
public static String getFilteredTrace(Throwable t)
Returns a filtered stack trace.
This is ripped out of junit.runner.BaseTestRunner.
t
- the exception to filter.
- the filtered stack trace.
main
public static void main(String[] args)
throws IOException
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 |
args
- the command line arguments.
startTest
public void startTest(Test t)
Interface TestListener.
A new Test is started.