Class MultiTest
- All Implemented Interfaces:
Test
You must add individual test case methods to your derived test class to create a useful test class. Each test case method must take no arguments. If you need to pass an argument into a test method, you should design a wrapper test case to calculate the argument values and then call the test method with the correct arguments. The test case methods must implement this interface:
public Status methodName( )
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionThe set of test cases to be excluded.protected PrintWriter
Output to be logged to result file.protected PrintWriter
Output that can be used as reference.protected static final Class<?>[]
protected String[]
Deprecated.protected final Class
<?> protected Method[]
The list of test case methods to be executed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
decodeAllArgs
(String[] argv) Parses the arguments passed to the test.protected int
Decode the next argument in the argument array.protected void
Generates a list of all test case methods.protected Method
getTestCase
(String testCase) Creates a test case method using the name of the method.protected void
init()
A setup method called after argument decoding is complete, and before the test cases are executed.protected Status
Deprecated.Use decodeArg(String and init() instead.protected Status
final Status
run
(String[] argv, PrintStream log, PrintStream ref) Run the test contained in this object.run
(String[] argv, PrintWriter log, PrintWriter ref) Run the test contained in this object.
-
Field Details
-
testClass
-
testArgTypes
-
log
Output to be logged to result file.Output to this PrintWriter is not used during golden file comparison. Also used to output the Status from each individual test case.
-
ref
Output that can be used as reference.Output to this PrintWriter is used during golden file comparison.
-
testMethods
The list of test case methods to be executed.An array of test case methods to be executed. It is usually filled up with the values by the decodeArg method.
-
testCases
Deprecated.Formerly served as the list of test case methods to be executed.Left for backward compatibility only. Due to be deleted soon.
-
excludeTestCases
The set of test cases to be excluded.
-
-
Constructor Details
-
MultiTest
public MultiTest()
-
-
Method Details
-
run
Run the test contained in this object.Implements Test.run using reflection to call test methods specified in the testMethods array. Each test method specified in the testMethods array can take no arguments.
This method is a convenience wrapper around the primary run method which takes PrintWriters: this variant takes PrintStreams and wraps them into PrintWriters.
- Parameters:
argv
- Execute arguments passed in from either the command line or the execution harness.log
- Output stream for general messages from the tests.ref
- Output stream for reference output from the tests.- Returns:
- Overall status of running all of the test cases.
- See Also:
-
run
Run the test contained in this object.Implements Test.run using reflection to call test methods specified in the testMethods array. Each test method specified in the testMethods array can take no arguments.
This method calls the decodeAllArgs method with the value of argv to decode command line arguments, and then calls the init method to perform any other initialization. To add parsing for new arguments you need to override the decodeArg method. The init method may also be overridden in case you need additional initialization.
- Specified by:
run
in interfaceTest
- Parameters:
argv
- Execute arguments passed in from either the command line or the execution harness.log
- Output stream for general messages from the tests. Is assigned to this.log.ref
- Output stream for reference output from the tests. Is assigned to this.ref.- Returns:
- Overall status of running all of the test cases.
- See Also:
-
decodeAllArgs
Parses the arguments passed to the test.This method embodies the main for loop for all of the execute arguments. It calls
decodeArg
for successive arguments in the argv array.- Parameters:
argv
- execute arguments from the test harness or from the command line.- Throws:
MultiTest.SetupException
- raised when an invalid parameter is passed, or another error occurred.- See Also:
-
decodeArg
Decode the next argument in the argument array. May be overridden to parse additional execute arguments.The default behavior of decodeArg( String argv[], int index ) is to parse test case IDs starting from
index
from execute argumentsargv
.The derived class may override this method to provide parsing of additional arguments. However, it is recommended for this method to return super.decodeArg() if it does not recognize the argument. So it has to parse specific for derived class arguments only.
The required syntax for using this method is the execute argument -TestCaseID followed by a space and then a space delimited list of one or more test case method names. Using the test case method name ALL specifies that all of the individual test case methods that match the required test method signature should be executed. The method getAllTestCases() is called to gather the list of all methods that match the test method signature.
Once the execute argument -TestCaseID is found, all subsequent execute arguments will be treated as test case method names until either the execute argument array is exhausted or an execute argument that begins with - is found.
- Parameters:
argv
- execute arguments from the test harness or from the command lineindex
- current index into argv.- Throws:
MultiTest.SetupException
- raised when an invalid argument is passed, or another error occurred.- See Also:
-
init
A setup method called after argument decoding is complete, and before the test cases are executed. By default, it does nothing; it may be overridden to provide additional behavior.- Throws:
MultiTest.SetupException
- if processing should not continue. This may be due to some inconsistency in the arguments, or if it is determined the test should not execute for some reason.
-
getTestCase
Creates a test case method using the name of the method.This method uses reflection to find the method with given name that implement the standard test case method signature:
public Status methodName( )
If no such method could be found, a SetupException is thrown.
NOTE: You will want to override this method if there are methods in your test class that match the test method signature that should not be executed as part of the test. As an example, see the SerializeTests base class.
- Throws:
MultiTest.SetupException
- raised when no method with given name and signature is found, or another error occurred.- See Also:
-
invokeTestCase
-
getAllTestCases
Generates a list of all test case methods.This method uses reflection to examine all of the public methods of the test class to find those methods that implement the standard test case method signature:
public Status methodName( )
If no methods matching this signature could be found, a SetupException is thrown. If at least one method matching the signature is found, this method assigns that list to the testMethods array.
NOTE: You will want to override this method if there are methods in your test class that match the test method signature that should not be executed as part of the test. As an example, see the SerializeTests base class.
- Throws:
MultiTest.SetupException
- raised when no methods matching the test method signature is found, or another error occurred.- See Also:
-
reverse
-
init
Deprecated.Use decodeArg(String and init() instead.Initialize the test from the given arguments.
-