Interface TestCase

All Known Implementing Classes:

public interface TestCase

The base interface for all test cases. Application test designers must derive their tests from TestCase directly or indirectly. The same TestCase class can be used in many test suites , or even in the same suite with different test parameters. Since TestCases are stateful , they cannot be shared. Thereforre , a new instance is created for every TestCase. TestCase implementers must provide the implementation class with a default constructor.

Method Summary
 void init(TestParameters params)
          Initializes the TestCase with the given test parameters.
 void test(java.io.PrintStream output)
          Runs the test.

Method Detail


public void init(TestParameters params)
          throws ParameterException
Initializes the TestCase with the given test parameters. The framework validates any input requested by the test , and throws InvalidParameterTypeException for invalid data. The test case developer can throw any extention of the ParameterException if the test does not approve one of the parameters. Optional paramters should be implemented as follows:

 public void init(TestParameters params) throws ParameterException {
   bytes = params.getBytesArray("data");
   try {
     optionalParam = params.getString("optionalParam");
   catch(MissingParameterException mpe) {
      // do nothing
params - The object containing the test data (parameters).
ParameterException - if a requested paramter is missing or invalid. User code can throw a ParameterException (or a subclass) to indicate inappropriate values.


public void test(java.io.PrintStream output)
          throws java.lang.Throwable
Runs the test. The test can make use of the OutputStream object to log interactions with the tested software or log test results.
The method should exit normally if it executed well -- all results are as expected and no exceptions of any kind were generated. The method should throw an exception of any kind when it runs into probems. Unitee framework will catch the exception and mark the test case as failed.

The test case developer should not try to catch any exception just to print the exception stack trace. Instead , the test case should focus on the methods to be tested using the given test parameters passed in via init(). If the test developer developes pesimistic test cases (which are recommanded) , any exception that is expected to be raised under these conditions , may be logged , but it must not fail the Test.

output - The output stream to which the test case should write diagnostics and informatories.
java.lang.Throwable - If any user code fails