The JavaTestingInvoker interface is the manager object that executes the Java test invocations. At the start of testing it is initialized, then asked to run each test case, and closed at the end of testing.
The test invoker is initialized with the ClassLoaders that make the classes being part of the testing accessible to the test invoker. The test invoker can decide to manage the test execution in an implementation dependent way.
The test invoker is considered to be an overall environment provider during the testing. It is a stateful object and test implementations may access various aspects of the test invoker. The test invoker should be accessible to the test case classes.
Clients may implement this interface. However, they are recommended to extend one of the basic test invoker API classes that integrate with the incremental testing instrumentation of the build task. See BasicInstrumentationJavaTestInvoker.
Implementations must have a public no-arg constructor.
public default void | close() Closes this test invoker. |
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 JavaTestInvocationResult | invokeTest( Invokes a test case. |
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
.
This method is called after 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 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
.)