OOoRunner test harness

lib
Class TestCase

java.lang.Object
  |
  +--lib.TestCase
Direct Known Subclasses:
BasicTestCase

public abstract class TestCase
extends Object

TestCase represent a factory for TestEnvironments creation and disposing for a given implementation object. The TestEnvironment contains an instance of the implementation object and all additional objects needed to perform tests on the object.

The TestCase provides four methods for its subclasses to define its functionality: initialize(), cleanup(), createTestEnvironment() and disposeTestEnvironment(). The first two are intended to initialize and cleanup common objects shared among all instances of TestEnvironment produced by the TestCase, and they are called at the beginning and at the end of the TestCase lifecycle accordingly.

The other two are intended to produce and dispose TestEnvironment instances. The createTestEnvironment() is called to create a TestEnvironment instance and the disposeTestEnvironment() is called when the instane is not used anymore.

See Also:
TestEnvironment

Field Summary
 PrintWriter log
          Specifies the PrintWriter to log information.
 
Constructor Summary
TestCase()
           
 
Method Summary
protected  void cleanup(TestParameters tParam, PrintWriter log)
          Called while the TestCase cleanup.
 void cleanupTestCase(TestParameters tParam)
          Cleans up the TestCase.
protected  void cleanupTestEnvironment(TestParameters Param, TestEnvironment tEnv, PrintWriter log)
          Called while disposing a TestEnvironment.
protected abstract  TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log)
          Called to create an instance of TestEnvironment with an object to test and related objects.
 void disposeTestEnvironment(TestEnvironment tEnv, TestParameters tParam)
          Disposes the TestEnvironment when it is not needed anymore.
 String getObjectName()
           
 TestEnvironment getTestEnvironment(TestParameters tParam)
          Creates a TestEnvironment containing an instance of the implementation object and related objects needed to perform test.
protected  void initialize(TestParameters tParam, PrintWriter log)
          Called while the TestCase initialization.
 void initializeTestCase(TestParameters tParam)
          Initializes the TestCase.
 void setLogWriter(PrintWriter log)
          Sets the log to write information during testing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public PrintWriter log
Specifies the PrintWriter to log information.
Constructor Detail

TestCase

public TestCase()
Method Detail

setLogWriter

public void setLogWriter(PrintWriter log)
Sets the log to write information during testing.

initializeTestCase

public void initializeTestCase(TestParameters tParam)
Initializes the TestCase. Calls initialize() method.
Parameters:
tParam - test parameters.

initialize

protected void initialize(TestParameters tParam,
                          PrintWriter log)
Called while the TestCase initialization. In the implementation does nothing. Subclasses can override to initialize objects shared among all TestEnvironments.
Parameters:
tParam - test parameters
log - writer to log information while testing
See Also:
#initializeTestCase()

cleanupTestCase

public void cleanupTestCase(TestParameters tParam)
Cleans up the TestCase. Calls cleanup().
Parameters:
tParam - test parameters

cleanup

protected void cleanup(TestParameters tParam,
                       PrintWriter log)
Called while the TestCase cleanup. In the implementation does nothing. Subclasses can override to cleanup objects shared among all TestEnvironments.
Parameters:
tParam - test parameters
log - writer to log information while testing
See Also:
cleanupTestCase(lib.TestParameters)

getTestEnvironment

public TestEnvironment getTestEnvironment(TestParameters tParam)
Creates a TestEnvironment containing an instance of the implementation object and related objects needed to perform test.
Parameters:
tParam - test parameters
Returns:
the created TestEnvironment
See Also:
#createTestEnvironment(), TestEnvironment

disposeTestEnvironment

public void disposeTestEnvironment(TestEnvironment tEnv,
                                   TestParameters tParam)
Disposes the TestEnvironment when it is not needed anymore. The method calls cleanupTestEnvironment().
Parameters:
tEnv - the environment to dispose
tParam - test parameters
See Also:
#cleanupTestEnvironment()

createTestEnvironment

protected abstract TestEnvironment createTestEnvironment(TestParameters tParam,
                                                         PrintWriter log)
Called to create an instance of TestEnvironment with an object to test and related objects. Subclasses should implement this method to provide the implementation and related objects. The method is called from getTestEnvironment().
Parameters:
tParam - test parameters
log - writer to log information while testing
See Also:
TestEnvironment, #getTestEnvironment()

cleanupTestEnvironment

protected void cleanupTestEnvironment(TestParameters Param,
                                      TestEnvironment tEnv,
                                      PrintWriter log)
Called while disposing a TestEnvironment. In the implementation does nothing. Subclasses can override to clean up the environments created by them.
Parameters:
tParam - test parameters
tEnv - the environment to cleanup
log - writer to log information while testing
See Also:
TestEnvironment, #disposeTestEnvironment()

getObjectName

public String getObjectName()
Returns:
the name of the object

OOoRunner test harness