The test invoker will properly initialize the classloaders that can be used to load the user and test classes. It is an abstract class that should be subclassed to specialize how the testing is performed.
When a test is executed, the class will synchronize
on BasicJavaTestingInvoker.class
and
acquire an exclusive lock during the invocation of a test case. It will replace the standard I/O fields in
System, and reset the system properties.
It will also set the thread context classloader to the test classloader. The standard I/O is buffered, and will be set as the failure information of the test result.
When a test execution is over, the class restores the mocked system fields.
Clients should subclass this class.
public | Creates a new testing invoker. |
public void | close() Closes this test invoker. |
protected ClassLoader | createTestsClassLoader( Creates the test classloader. |
protected ClassLoader | createUserClassLoader( Creates the user classloader. |
protected final ClassLoader | Gets the test classloader. |
protected final ClassLoader | Gets the test runner classloader. |
protected final ClassLoader | Gets the user classloader. |
public void | initClassLoaders( Requests the test invoker to perform the initialization of the ClassLoaders for the user and test
classpath. |
public void | initTestRunner( Initializes the test runner. |
public final JavaTestInvocationResult | invokeTest( Invokes a test case. |
protected abstract JavaTestInvocationResult | invokeTestImpl( Invokes the test. |
This method is called when no more test are executed using this invoker.
The test invoker should clean up any possible resources that were allocated by the test cases.
Closes this stream and releases any system resources associated with it.If the stream is already closed then invoking this method has no effect.
As noted in AutoCloseable.close(), cases where the
close may fail require careful attention. It is strongly advised
to relinquish the underlying resources and to internally
mark the Closeable
as closed, prior to throwing
the IOException
.
Clients may override to perform custom initialization.
null
.) This is not the same as in
initClassLoaders, but a classloader that provides access to the user classloader and test runner
classloader as well.Clients may override to perform custom initialization.
null
.) This is the same as passed to
initClassLoaders.The test classloader contains the test case classes.
The test runner classloader contains the classes for the used testing framework.
The user classloader contains the classes being tested.
This method is called after JavaTestingInvoker.initTestRunner(
The user class loader is the one that contains the classes being tested. The test class loader is the one that contains the test cases.
The relations between the constructed classloaders may be implementation dependent for the test invoker. However, we recommend that the user classloader is constructed with the specified parent as its parent, and the test classloader is constructed with the specified parent, the user classloader, and the test runner classloader as its parent. The BasicJavaTestingInvoker class initializes them this way.
null
.)null
.)This method is called first as part of the initialization.
The method should perform the operations that required in order to locate the test runner that will execute the tests. This can be done in an implementation dependent way.
In common implementations, the method will attempt to load a class that will be called with the test classes as
its input in the JavaTestingInvoker.invokeTest(
One example for this may be that is to find the entry point of the testing framework that contains a
main
method. That main
method is caleld for each test in
invokeTest.
this
testing invoker.This method is called after the initialization was performed.
The test invoker should invoke the test class specified with the given parameters. It may do so in an implementation dependent manner.
The file provider parameter can be used by test case instrumentation to request files that are being accessed by the test cases. The BasicInstrumentationJavaTestInvoker subclass handles it appropriately.
The result of the test is returned from this function. Exceptions thrown by the test cases shouldn't be relayed to the caller. The test result object should contain any failure information. It can also be used to report the dependencies of the test case.
null
.)
This method is called by invokeTest(
The arguments are the same as for the invokeTest method.
null
.)