Package com.sun.javatest.lib
Class MultiTest
- java.lang.Object
-
- com.sun.javatest.lib.MultiTest
-
- All Implemented Interfaces:
Test
public class MultiTest extends java.lang.Object implements Test
Base class for tests with multiple sub test cases. This base class implements the standard com.sun.javatest.Test features so that you can provide the additional test cases without concern about the boilerplate needed to execute individual test case methods.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 Modifier and Type Class Description static class
MultiTest.SetupException
This exception is thrown when a problem occurs initializing the test.
-
Constructor Summary
Constructors Constructor Description MultiTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
decodeAllArgs(java.lang.String[] args)
Parses the arguments passed to the test.protected int
decodeArg(java.lang.String[] args, int index)
Decode the next argument in the argument array.protected void
init()
A setup method called after argument decoding is complete, and before the test cases are executed.protected Status
init(java.lang.String[] args)
Deprecated.UsedecodeArg(String)
andinit()
instead.protected Status
invokeTestCase(java.lang.reflect.Method m)
Default way to invoke a specified test case.Status
run(java.lang.String[] argv, java.io.PrintStream log, java.io.PrintStream ref)
Run the test cases contained in this object This method is a convenience wrapper around the primary run method which takes PrintWriters: this variant takes PrintStreams and wraps them into PrintWriters.Status
run(java.lang.String[] args, java.io.PrintWriter log, java.io.PrintWriter ref)
Run the test cases contained in this object.
-
-
-
Method Detail
-
run
public Status run(java.lang.String[] args, java.io.PrintWriter log, java.io.PrintWriter ref)
Run the test cases contained in this object. The test cases are determined and invoked via reflection. The set of test cases can be specified with -select case1,case2,case3... and/or restricted with -exclude case1,case2,case3...- Specified by:
run
in interfaceTest
- Parameters:
args
- 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:
decodeAllArgs(java.lang.String[])
,init(java.lang.String[])
-
run
public final Status run(java.lang.String[] argv, java.io.PrintStream log, java.io.PrintStream ref)
Run the test cases contained in this object 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:
decodeAllArgs(java.lang.String[])
,init(java.lang.String[])
-
init
protected Status init(java.lang.String[] args)
Deprecated.UsedecodeArg(String)
andinit()
instead.Initialize the test from the given arguments. The arguments will be passed todecodeAllArgs
, and theninit()
will be called.- Parameters:
args
- The arguments for the test, passed todecodeArgs
.- Returns:
- null if initialization is successful, or a status indicating why initialization was not successful.
- See Also:
decodeAllArgs(java.lang.String[])
,decodeArg(java.lang.String[], int)
,init()
-
init
protected void init() throws MultiTest.SetupException
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.
-
decodeAllArgs
protected final void decodeAllArgs(java.lang.String[] args) throws MultiTest.SetupException
Parses the arguments passed to the test. This method embodies the main loop for all of the test's arguments. It callsdecodeArg
for successive arguments in the argument array.- Parameters:
args
- arguments passed to the test.- Throws:
MultiTest.SetupException
- raised when an invalid parameter is passed, or another error occurred.- See Also:
decodeArg(java.lang.String[], int)
-
decodeArg
protected int decodeArg(java.lang.String[] args, int index) throws MultiTest.SetupException
Decode the next argument in the argument array. This will typically be overridden by subtypes that wish to decode additional arguments. If an overriding method does not recognize an argument, it should returnsuper.decodeArg(args, index)
to give supertypes a change to decode the argument as well.- Parameters:
args
- The array containing all the argumentsindex
- The position of the next argument to be decoded.- Returns:
- the number of elements in the array were "consumed" by this call.
- Throws:
MultiTest.SetupException
- is there is a problem decoding the argument.
-
invokeTestCase
protected Status invokeTestCase(java.lang.reflect.Method m) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Default way to invoke a specified test case.- Parameters:
m
- The method to be invoked.- Returns:
- The result of invoking the specified test case.
- Throws:
java.lang.IllegalAccessException
- if there was a problem accessing the specified methodjava.lang.reflect.InvocationTargetException
- if the specified method threw an exception when it was invoked.
-
-