Unit Test Frameworks
Test |
Description
The abstract class Test (see Figure C-16) is the central design element of CppUnit, as in other versions of xUnit. It is the base class for all test objects. A Test may consist of a single unit test or of a collection of Test s. When a Test is run, a TestResult collects its results.
All of Test 's methods are virtual and should be overridden by descendant classes.
Test belongs to the namespace CppUnit . It is declared in Test.h and implemented in Test.cpp .
Figure C-16. The abstract class Test
Declaration
class Test
Constructors/Destructors
-
- virtual ~Test( )
-
A destructor.
Public Methods
-
- virtual int countTestCases( ) const = 0
-
Returns the number of test cases to be run by this Test .
-
- virtual string getName( ) const = 0
-
Returns the name of this Test .
-
- virtual void run(TestResult *result) = 0
-
Runs Test and collects the results in result .
-
- virtual string toString( ) const = 0
-
Returns a short description of this Test , generally incorporating the name and Test type.
Protected/Private Methods
None.
Attributes
None.