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.
![]() |
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
Testobjects.
Public Methods
-
void addTest(Test *test) Adds a
Testto thisTestSuite.-
int countTestCases( ) const Returns the total number of
TestCaseobjects to be run by thisTestSuite, by recursively callingcountTestCases( )on all the containedTestobjects.-
virtual void deleteContents( ) Deletes all the contained
Testobjects.-
string getName( ) const Returns the name of this
TestSuite.-
const vector<Test *> &getTests( ) const Returns the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
