Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TestCase Class Reference
[Test Case Support]

#include <TestCase.h>

Inheritance diagram for TestCase:

TestCaseGenericSetUp TestCaseBasicDatabase_1 TestCaseBasicDataPool_1 TestCaseByteArrayTelemetryStream_1 TestCaseChecksum_1 TestCaseControlAction_1 TestCaseCycleDataItem16TmStream_1 TestCaseDataItem16TmWord_1 TestCaseDataItem_1 TestCaseDeltaProfile_1 TestCaseDummyConditionalPunctualAction_1 TestCaseDummyConfigurableManoeuvre_1 TestCaseDummyCriticalTelecommand_1 TestCaseDummyDatabase_1 TestCaseDummyDataPool_1 TestCaseDummyFsmState_1 TestCaseDummyObsClock_1 TestCaseDummyPUSTelecommand_1 TestCaseDummyPUSTelemetryPacket_1 TestCaseDummyTelecommand_1 TestCaseDummyTelecommandLoader_1 TestCaseDummyTelemetryPacket_1 TestCaseDummyTelemetryStream_1 TestCaseDummyTracer_1 TestCaseEvent_1 TestCaseEventRepository_1 TestCaseEventRepository_2 TestCaseEventRepository_3 TestCaseFdirCheck_1 TestCaseFileTelemetryStream_1 TestCaseFileTelemetryStream_2 TestCaseForbiddenValueProfile_1 TestCaseFromFsmEvent_1 TestCaseFSM_2 TestCaseFSM_3 TestCaseFsmEvent_1 TestCaseInRangeProfile_1 TestCaseManoeuvrePunctualAction_1 TestCaseMatlabCopyPID_1 TestCaseMatlabDataItemPID_1 TestCaseMatlabDataPoolPID_1 TestCaseMatlabPointerPID_1 TestCaseNestedFsmActivator_1 TestCaseNestedFsmActivatorWithEndState_1 TestCaseNestedFsmActivatorWithExitCheck_1 TestCaseNullProfile_1 TestCaseOutOfRangeProfile_1 TestCasePunctualActionManager_1 TestCaseRawDataItem_1 TestCaseRecoveryAction_1 TestCaseRootObject_1 TestCaseRootObject_2 TestCaseRootObject_3 TestCaseSimpleChangeProfile_1 TestCaseSimplePunctualActionModeManager_1 TestCaseSimpleTelemetryModeManager_1 TestCaseStuckDataProfile_1 TestCaseTelecommandManager_1 TestCaseTelecommandManager_2 TestCaseTelecommandManager_3 TestCaseTelemetryManager_1 TestCaseTestTracer_1 TestCaseUnstableFsmState_1 TestCaseWithEvtCheck List of all members.

Detailed Description

Base class from which all classes encapsulating a test case are derived.

A test case is a self-contained, and usually small test, that can either fail or succeed. The class encapsulating a test case is completely responsible for running the test from the set-up of the test conditions to the shut-down of the test and for reporting its outcome. A test case class is however "passive" in the sense that it has the capabilities to initiate, perform and terminate a test but these capabilities must be controlled by some external entity.

This class declares, and defines trivial default implementations for, four services. The test set-up service set up the conditions for the performance of the test case. The test execution service causes the test case to be executed. This service should only be called after the test set-up service was called. The test shut-down service performs any shut-down actions that may be required at the end of the test case. It should always be called at the end of a test case. The test reporting service reports the outcome of the test. The outcome of the test is made up of a true/false flag (the test outcome)and an explanatory message that contains additional information about its outcome (the test message).

This class defines two attributes for test cases. The test case ID is an integer acting as a numerical identifier of the test case. The test case name is a string that represent the name of the test case.

This class is abstract because the test execution service must be defined by subclasses representing concrete test cases. Default implementations are instead provided for the test set up and shut down services.

A pseudo-code example of how a test case could be run is as follows:

   testCase.setUpTestCase();
   testCase.runTestCase();
   testCase.shutDownTestCase();
   bool outcome = testCase.getTestOutcome();
   char* testMessage = testCase.getTestMessage();
  
IMPORTANT NOTICE: the framework classes are designed to prevent class instances from ever being destroyed (this applies both to explicit object deletion and to implicit deletion when an object variable goes out of scope). This presents a problem for the implementation of test cases since each test case should have its own set of variables in order to preserve the mutual independence of test cases. The solution adopted here is that each test case creates the class variables it needs dynamically on the heap but does not destry them when it terminates. This means that execution of a test case introduces a memory leak. The size of the memory leak should not cause any problems in a desktop environment.

Todo:
reformulate comments to test cases in terms of "checks" rather than "verification".
See also:
TestSuite
Author:
Alessandro Pasetti (P&P Software GmbH)
Version:
1.0

Definition at line 72 of file TestCase.h.

Public Member Functions

 TestCase (int testId, char *testName)
 Constructor defining the test case ID and the test case name.

virtual bool setUpTestCase (void)
 This method implements the test set up service.

virtual void runTestCase (void)=0
 This method implements the test execution service.

virtual bool shutDownTestCase (void)
 This method implements the test shut down service.

char * getTestName (void) const
 Return the test name.

bool getTestOutcome (void) const
 Return the test outcome.

char * getTestMessage (void) const
 Return the test message.


Protected Member Functions

void setTestResult (bool outcome, char *testMessage)
 Method intended to be called by concrete test cases to set the test outcome flag and the test message.

bool isNonNominalCheckAllowed (void) const
 Return true if non-nominal behaviour can be checked.


Constructor & Destructor Documentation

TestCase::TestCase int  testId,
char *  testName
 

Constructor defining the test case ID and the test case name.

Parameters:
testId the test case ID
testName the test case name as a string

Definition at line 16 of file TestCase.cpp.


Member Function Documentation

char * TestCase::getTestMessage void   )  const
 

Return the test message.

The test message can be an empty string (e.g. " ") but should never be the null string.

Returns:
the test name.

Definition at line 65 of file TestCase.cpp.

char * TestCase::getTestName void   )  const
 

Return the test name.

Returns:
the test name.

Definition at line 57 of file TestCase.cpp.

bool TestCase::getTestOutcome void   )  const
 

Return the test outcome.

Returns:
the test name.

Definition at line 61 of file TestCase.cpp.

bool TestCase::isNonNominalCheckAllowed void   )  const [protected]
 

Return true if non-nominal behaviour can be checked.

Some test cases may want to check the behaviour of the class under test under non-nominal conditions. In general, this should only be done if violation of an assertion check does not lead to a termination of the application. This is because the non-nominal situation might be caught by an assertion check which might lead to a premature termination of the test. This method returns true if violation of an assertion check does not lead to termination of the application. The method is implemented in terms of the pre-processor symbols NDEBUG and USE_SYSTEM_ASSERT defined in the include file CompilerSwitches.h.

Returns:
true if if violation of an assertion check does not lead to termination of the application, false otherwise

Definition at line 41 of file TestCase.cpp.

void TestCase::setTestResult bool  outcome,
char *  testMessage
[protected]
 

Method intended to be called by concrete test cases to set the test outcome flag and the test message.

This method should only be called once in a given test case. Attempts to call it more than once will result in an error message being stored in the test message and in the test outcome flag having an undefined value.

Parameters:
outcome the test outcome flag
testMessage the test message string

Definition at line 25 of file TestCase.cpp.

bool TestCase::setUpTestCase void   )  [virtual]
 

This method implements the test set up service.

This class provides a default implementation that always returns "set up was successful".

Returns:
true if the test set up succeeded, false otherwise

Reimplemented in TestCaseGenericSetUp, TestCasePUSFull, TestCaseWithEvtCheck, and TestCaseWithFactories.

Definition at line 53 of file TestCase.cpp.

bool TestCase::shutDownTestCase void   )  [virtual]
 

This method implements the test shut down service.

This class provides a default implementation that always returns "shut down was successful".

Returns:
true if the test shut down succeeded, false otherwise

Reimplemented in TestCaseGenericSetUp, TestCasePUSFull, and TestCaseWithFactories.

Definition at line 49 of file TestCase.cpp.


The documentation for this class was generated from the following files:
Copyright 2003 P&P Software GmbH - All Rights Reserved