Use ITest to derive subclasses for testing features of your test targets. ITest provides an output stream in which you can record any tesxt output. ITest provides input text arguments that you can use to parameterize the kind of test to be performed. Meta-information on the test may also be defined and obtained using the copyInfo and lookupInfo methods.
Constructors & DestructorClass constructors and destructors.
![]() |
public:
virtual ~ITest()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
ITest(const ITest& test)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
protected:
ITest()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Assignment OperatorsUse this operator to assign an ITest class to another.
![]() |
public:
ITest& operator =(const ITest& test)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
ExceptionsClass exception member functions used to determine the status of a test run.
![]() |
public:
virtual EStage exceptionStage() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
ExecutionClass member functions used to execute the test.
![]() |
public:
virtual void run()
Derived classes should not override this function. The run function calls following the framework methods:
Each time run is called, it increments the value returned by runCount.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Execution ResultsClass member functions used to determine that status of the test.
![]() |
public:
virtual unsigned long runCount() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
bool success() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Input ConfigurationManipulate the test's input arguments.
![]() |
public:
void copyInputs(int& argc, char * *& argv) const
Copies parameters that take UNIX-style parameters to argv.
Derived classes should not override this function.
You can call copyInputs after running a test to correlate inputs with the test results. The caller owns the string array and should delete the storage.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setInputs(const int argc, const char * const* argv)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Main Testing FunctionsMain member functions used to setup the actual tests.
![]() |
protected:
virtual void addInfo(const IString&, const IString&)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void cleanup()
Any actions within setup which need to be undone (for example, storage allocation), should be undone here.
ITest::run always calls cleanup, even if an exception occurs.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void print(ITieredTextBuffer&)
Note: The content of the print method is printed out only when you set (through the command line) the echotier level equal to or below ITieredTextBuffer::kDetail.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void reset()
Overriding methods should call the inherited method first. This method is used to perform necessary re-initialization operations for tests that can be run more than once. ITest::run calls this method before running a test a second or later time. ITest::run does not call reset before running a test for the first time. Derived classes that should not be run more than once, can use this method to ensure that multiple calls to run do no harm.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void setup()
Subclasses may override setup to perform any appropriate initialization before test is called. For example, a test might instantiate a target object to be tested if there is not one already.
Note: Anything that is done in setup should be undone, if necessary, in cleanup.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void test() = 0
The only ITest method that subclasses are required to call inside a test is setSuccess.
Note: Derived classes must override this method, even if they do not override any of the other methods in this class.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Meta-informationMember functions used to setup or retrieve test meta information.
![]() |
public:
virtual void copyInfo()
You can specify various types of meta-information, including the purpose of a test and the name of the class being tested. You can retrieve and display this information by using the -info option when you start RunTest.
When you assign information to a test, associate each test class with key/value pairs in a dictionary. This supports categorization of different kinds of tests and analysis of large numbers of test results.
The text values for the keys can be used with the -info option of RunTest to query a specific key/value pair in the dictionary. The following shows the predefined keys and values:
KEY KEYWORD(VALUE) DESCRIPTION
--------------- -------------- -------------------------------------
kDescriptionKey Description Description of this test subclass
kInputSyntaxKey Input Syntax Input syntax for text arguments
kTargetClassKey Target Class Name of target class
kTestNameKey Test Name Name of test
kTestVersionKey Test Version Version number of test
kTestTypeKey Test Type Type of test (eg. unit, regression, etc.)
kComponentKey Component Name of component to which this test applies
Inside of copyInfo, derived classes should call the inherited implementation
(IDerived::copyInfo should call IBase::copyInfo). Then copyInfo should add
key/value pairs to infoMap by calling the addInfo method.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
virtual bool lookupInfo(const IString& key, IString& info)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void addInfo(const IString&, const IString&)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
OutputMember functions used by the tests to display output.
![]() |
public:
ITieredTextBuffer& outputTextStream()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void print(ITieredTextBuffer&)
Note: The content of the print method is printed out only when you set (through the command line) the echotier level equal to or below ITieredTextBuffer::kDetail.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Public Data MembersPublic data members used to store meta-information about this test. See the member functions copyInputs, setInputs, copyInfo, lookupInfo, and addInfo.
![]() |
public:
static const IString & _Import kComponentKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
static const IString& kComponentKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const IString & _Import kDescriptionKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
static const IString& kDescriptionKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const IString& kInputSyntaxKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
static const IString & _Import kInputSyntaxKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const IString & _Import kTargetClassKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
static const IString& kTargetClassKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const IString & _Import kTestNameKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
static const IString& kTestNameKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const IString & _Import kTestTypeKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
static const IString& kTestTypeKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const IString& kTestVersionKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
static const IString & _Import kTestVersionKey
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Test ControlMember functions used to control the test status keeping.
![]() |
public:
void copyInputs(int& argc, char * *& argv) const
Copies parameters that take UNIX-style parameters to argv.
Derived classes should not override this function.
You can call copyInputs after running a test to correlate inputs with the test results. The caller owns the string array and should delete the storage.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setInputs(const int argc, const char * const* argv)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual bool isReset() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual bool isSuccessUndecided() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void setStickySuccess(bool success)
The difference between setStickySuccess and setSuccess is that setStickySuccess is called to preserve the failure of a test until the next run of the test. Once setStickySuccess is called with false, the success value will remain false from that point on. It can no longer be changed to true even if setSuccess or setStickySuccess is called with true. If a test is run more than once, the "sticky" flag will be reset in ITest:reset so that success can be set to any value in the next run of the test.
Derived classes can call setStickySuccess at anytime, but especially during test to indicate the test's success.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void setSuccess(bool success)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
enum EStage { kNone,
kRun,
kReset,
kSetup,
kTest,
kCleanup }
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |