public class JUnitTestRunner extends Object implements JUnitTaskMirror.JUnitTestRunnerMirror
<code>
public static junit.framework.Test suite()
</code>
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.ERRORS, FAILURES, IGNORED_FILE_NAME, SUCCESS| Constructor and Description |
|---|
JUnitTestRunner(String platformHome,
String classpath,
String webClasspath,
JUnitTest test,
boolean haltOnError,
boolean filtertrace,
boolean haltOnFailure)
Constructor for fork=true or when the user hasn't specified a classpath.
|
JUnitTestRunner(String platformHome,
String classpath,
String webClasspath,
JUnitTest test,
boolean haltOnError,
boolean filtertrace,
boolean haltOnFailure,
boolean showOutput)
Constructor for fork=true or when the user hasn't specified a classpath.
|
JUnitTestRunner(String platformHome,
String classpath,
String webClasspath,
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(String platformHome,
String classpath,
String webClasspath,
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(String platformHome,
String classpath,
String webClasspath,
JUnitTest test,
boolean haltOnError,
boolean filtertrace,
boolean haltOnFailure,
boolean showOutput,
ClassLoader loader)
Constructor to use when the user has specified a classpath.
|
JUnitTestRunner(String platformHome,
String classpath,
String webClasspath,
JUnitTest test,
boolean haltOnError,
boolean filtertrace,
boolean haltOnFailure,
ClassLoader loader)
Constructor to use when the user has specified a classpath.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addError(Test test,
Throwable t)
Interface TestListener.
|
void |
addFailure(Test test,
AssertionFailedError t)
Interface TestListener for JUnit > 3.4.
|
void |
addFailure(Test test,
Throwable t)
Interface TestListener for JUnit <= 3.4.
|
void |
addFormatter(JUnitResultFormatter f)
Add a formatter.
|
void |
addFormatter(JUnitTaskMirror.JUnitResultFormatterMirror f)
Add a formatter to the test.
|
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)
Handle output sent to System.err.
|
void |
handleErrorOutput(String output)
Handle output sent to System.err.
|
void |
handleFlush(String output)
Handle output sent to System.out.
|
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.
|
public JUnitTestRunner(String platformHome, String classpath, String webClasspath, JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure)
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.public JUnitTestRunner(String platformHome, String classpath, String webClasspath, JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput)
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.public JUnitTestRunner(String platformHome, String classpath, String webClasspath, JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, boolean logTestListenerEvents)
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.public JUnitTestRunner(String platformHome, String classpath, String webClasspath, JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, ClassLoader loader)
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.public JUnitTestRunner(String platformHome, String classpath, String webClasspath, JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, ClassLoader loader)
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.public JUnitTestRunner(String platformHome, String classpath, String webClasspath, JUnitTest test, boolean haltOnError, boolean filtertrace, boolean haltOnFailure, boolean showOutput, boolean logTestListenerEvents, ClassLoader loader)
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.public void run()
run in interface JUnitTaskMirror.JUnitTestRunnerMirrorpublic int getRetCode()
getRetCode in interface JUnitTaskMirror.JUnitTestRunnerMirrorpublic void startTest(Test t)
t - the test.public void endTest(Test test)
test - the test.public void addFailure(Test test,
Throwable t)
test - the test.t - the exception thrown by the test.public void addFailure(Test test,
AssertionFailedError t)
test - the test.t - the assertion thrown by the test.public void addError(Test test,
Throwable t)
test - the test.t - the error thrown by the test.public void setPermissions(Permissions permissions)
setPermissions in interface JUnitTaskMirror.JUnitTestRunnerMirrorpermissions - the permissions to use.public void handleOutput(String output)
handleOutput in interface JUnitTaskMirror.JUnitTestRunnerMirroroutput - the string to outputpublic int handleInput(byte[] buffer,
int offset,
int length)
throws IOException
handleInput in interface JUnitTaskMirror.JUnitTestRunnerMirrorbuffer - not used.offset - not used.length - not used.IOException - never.org.apache.tools.ant.Task#handleInput(byte[], int, int)public void handleErrorOutput(String output)
handleErrorOutput in interface JUnitTaskMirror.JUnitTestRunnerMirroroutput - output for System.errpublic void handleFlush(String output)
handleFlush in interface JUnitTaskMirror.JUnitTestRunnerMirroroutput - output for System.out.public void handleErrorFlush(String output)
handleErrorFlush in interface JUnitTaskMirror.JUnitTestRunnerMirroroutput - coming from System.errpublic void addFormatter(JUnitResultFormatter f)
f - the formatter to add.public void addFormatter(JUnitTaskMirror.JUnitResultFormatterMirror f)
addFormatter in interface JUnitTaskMirror.JUnitTestRunnerMirrorf - the formatter to use.public static void main(String[] args) throws IOException
| 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.IOException - on error.public static String getFilteredTrace(Throwable t)
t - the exception to filter.Copyright © 2017 SAP SE. All Rights Reserved.