Name

TestSuite

Description

The class TestSuite (see Figure C-31) implements the interface Test. It is a composite of Test objects. Since the contained Test objects may be instances of TestCase, TestSuite, or any other subclass of Test, this allows hierarchies of Test classes to be assembled and run as a unit. A TestSuite is run just like a TestCase: by calling its run( ) method and passing in a TestResult to receive the results. The TestSuite then sequentially runs the Test objects it contains.

A TestSuite takes ownership of all Test objects added to it and deletes them in its destructor.

TestSuite belongs to the namespace CppUnit. It is declared in the file TestSuite.h and implemented in the file TestSuite.cpp.

The class TestSuite
Figure C-31. The class TestSuite

Declaration

class TestSuite : public Test

Constructors/Destructors

TestSuite(string name = "")

Constructs a TestSuite, optionally giving it a name.

virtual ~TestSuite( )

A destructor. Deletes all the contained Test objects.

Public Methods

void addTest(Test *test)

Adds a Test to this TestSuite.

int countTestCases( ) const

Returns the total number of TestCase objects to be run by this TestSuite, by recursively calling countTestCases( ) on all the contained Test objects.

virtual void deleteContents( )

Deletes all the contained Test objects.

string getName( ) const

Returns the name of this TestSuite.

const vector<Test *> &getTests( ) const

Returns the ...

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.