CppUnit project page | FAQ

Public Member Functions | Private Attributes | List of all members
TestSuite Class Reference
Creating TestSuite

A Composite of Tests. More...

`#include <TestSuite.h>`

Inheritance diagram for TestSuite:
[legend]
Collaboration diagram for TestSuite:
[legend]

## Public Member Functions
| TestSuite (std::string name="")
| Default constructor. More...
| ~TestSuite ()
| Destructor. More...
void | addTest (Test *test)
| Adds a test to the suite. More...
const std::vector< Test * > & | getTests () const
virtual void | deleteContents ()
| Deletes all tests in the suite. More...
int | getChildTestCount () const
| Returns the number of direct child of the test. More...
Test * | doGetChildTestAt (int index) const
| Returns the child test of the specified valid index. More...
Public Member Functions inherited from TestComposite
| TestComposite (const std::string &name="")
| ~TestComposite ()
void | run (TestResult *result)
| Run the test, collecting results. More...
int | countTestCases () const
| Return the number of test cases invoked by run(). More...
std::string | getName () const
| Returns the test name. More...
Public Member Functions inherited from Test
virtual | ~Test ()
virtual void | run (TestResult *result)=0
| Run the test, collecting results. More...
virtual int | countTestCases () const =0
| Return the number of test cases invoked by run(). More...
virtual int | getChildTestCount () const =0
| Returns the number of direct child of the test. More...
virtual Test * | getChildTestAt (int index) const
| Returns the child test of the specified index. More...
virtual std::string | getName () const =0
| Returns the test name. More...
virtual bool | findTestPath (const std::string &testName, TestPath &testPath) const
| Finds the test with the specified name and its parents test. More...
virtual bool | findTestPath (const Test *test, TestPath &testPath) const
| Finds the specified test and its parents test. More...
virtual Test * | findTest (const std::string &testName) const
| Finds the test with the specified name in the hierarchy. More...
virtual TestPath | resolveTestPath (const std::string &testPath) const
| Resolved the specified test path with this test acting as 'root'. More...

## Private Attributes
std::vector< Test * > | m_tests

## Additional Inherited Members
Protected Member Functions inherited from Test
virtual void | checkIsValidIndex (int index) const
virtual Test * | doGetChildTestAt (int index) const =0
| Returns the child test of the specified valid index. More...

## Detailed Description

A Composite of Tests.

It runs a collection of test cases. Here is an example.

CppUnit::TestSuite *suite= new CppUnit::TestSuite();
suite->addTest(new CppUnit::TestCaller<MathTest> (
"testAdd", testAdd));
suite->addTest(new CppUnit::TestCaller<MathTest> (
"testDivideByZero", testDivideByZero));

Note that TestSuites assume lifetime control for any tests added to them.

TestSuites do not register themselves in the TestRegistry.

See also
  Test
  TestCaller

## Constructor & Destructor Documentation

## ◆ TestSuite()

CPPUNIT_NS_BEGIN TestSuite::TestSuite | ( | std::string | name = `""` | ) |

Default constructor.

Constructs a test suite with the specified name.

## ◆ ~TestSuite()

TestSuite::~TestSuite | ( |  | ) |

Destructor.

## Member Function Documentation

## ◆ addTest()

void TestSuite::addTest | ( | Test * | test | ) |

Adds a test to the suite.

Adds the specified test to the suite.

Parameters

  test | Test to add. Must not be `NULL`.

## ◆ deleteContents()

void TestSuite::deleteContents | ( |  | ) |
| virtual

Deletes all tests in the suite.

Destroys all the tests of the suite.

## ◆ doGetChildTestAt()

Test * TestSuite::doGetChildTestAt | ( | int | index | ) | const
| virtual

Returns the child test of the specified valid index.

Parameters

  index | Zero based valid index of the child test to return.

Returns
  Pointer on the test. Never `NULL`.

Implements Test.

## ◆ getChildTestCount()

int TestSuite::getChildTestCount | ( |  | ) | const
| virtual

Returns the number of direct child of the test.

Implements Test.

## ◆ getTests()

const std::vector< Test * > & TestSuite::getTests | ( |  | ) | const

Returns the list of the tests (DEPRECATED).

Deprecated:
  Use getChildTestCount() & getChildTestAt() of the TestComposite interface instead.

Returns
  Reference on a vector that contains the tests of the suite.

## Member Data Documentation

## ◆ m_tests

std::vector<Test *> TestSuite::m_tests
| private

The documentation for this class was generated from the following files:

- TestSuite.h
- TestSuite.cpp

| Send comments to: CppUnit Developers