Name

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 Tests. 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 .

The abstract class Test
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.

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.