saker.java.testing Documentation TaskDoc JavaDoc Packages
public class ReflectionJavaTestInvoker extends BasicInstrumentationJavaTestInvoker
BasicInstrumentationJavaTestInvoker subclass that invokes the main method of a specified test runner class.

The test invoker will execute a test case by passing it to the specified main(String[]) method as an argument. The called method may locate the test class by using the thread context classloader (which is set by the BasicJavaTestingInvoker superclass).

The test invoker should be configured using the parameters specified with the PARAMETER_* constants in the class.

The actual arguments for the main method call for a test case is constructed by taking the "PrefixArguments", <test-case-class-name>, and "SuffixArguments" parameters as values.

Fields
public static final String
PARAMETER_PREFIX_ARGUMENTS = "PrefixArguments"
Parameter specifying a list of arguments that should be prepended before the test class name when the main method is called.
public static final String
PARAMETER_SUFFIX_ARGUMENTS = "SuffixArguments"
Parameter specifying a list of arguments that should be appended after the test class name when the main method is called.
public static final String
PARAMETER_TEST_RUNNER_CLASS = "TestRunnerClass"
Required parameter specifying the name of the test runner class.
Constructors
public
Creates a new testing invoker.
Methods
protected final Method
Gets the test method.
protected final Class<?>
Gets the class of the test runner.
public void
initTestRunner(ClassLoader testrunnerclassloader, TestInvokerParameters parameters)
Initializes the test runner.
protected void
Executes the test with the given parameters.
public static final String PARAMETER_PREFIX_ARGUMENTS = "PrefixArguments"
Parameter specifying a list of arguments that should be prepended before the test class name when the main method is called.

The parameter should have a format of <param>[,<param>]*. The intermediate commas (,) can be escaped using a backslash (\).

public static final String PARAMETER_SUFFIX_ARGUMENTS = "SuffixArguments"
Parameter specifying a list of arguments that should be appended after the test class name when the main method is called.

The parameter should have a format of <param>[,<param>]*. The intermediate commas (,) can be escaped using a backslash (\).

public static final String PARAMETER_TEST_RUNNER_CLASS = "TestRunnerClass"
Required parameter specifying the name of the test runner class.

The class is loaded from the test runner class loader.

Creates a new testing invoker.
protected final Method getTestMethod()
Gets the test method.

This method is called for each test case, and has a single parameter with the type of String[].

The test method.
protected final Class<?> getTestRunnerClass()
Gets the class of the test runner.

This class contains the test method.

The test runner class.
public void initTestRunner(ClassLoader testrunnerclassloader, TestInvokerParameters parameters) throws JavaTestRunnerFailureException
Overridden from: JavaTestingInvoker
Initializes the test runner.

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(JavaTestingFileProvider, TestInvocationParameters) method.
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.

testrunnerclassloaderThe ClassLoader that is used to load the test runner classes. May be the same as the classloader of this testing invoker.
parametersThe test invoker parameters that are passed by the user as configuration.
JavaTestRunnerFailureExceptionIf the initialization failed-
Executes the test with the given parameters.

The method should succeed if and only if the test case is considered successful, and throw InvocationTargetException if the test case failed.

You can load the test class with the name TestInvocationParameters.getTestClassName() from the BasicJavaTestingInvoker.getTestClassLoader().

parametersThe test parameters.
JavaTestRunnerFailureExceptionIf the test runner encountered a failure during the invocation of the test.
InvocationTargetExceptionIf the test case failed.