CppUnit project page | FAQ |
Base class for all test objects. More...
#include <Test.h>
Public Member Functions | |
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... | |
Protected Member Functions | |
virtual void | checkIsValidIndex (int index) const |
virtual Test * | doGetChildTestAt (int index) const =0 |
Returns the child test of the specified valid index. More... | |
Base class for all test objects.
All test objects should be a subclass of Test. Some test objects, TestCase for example, represent one individual test. Other test objects, such as TestSuite, are comprised of several tests.
When a Test is run, the result is collected by a TestResult object.
|
inlinevirtual |
|
protectedvirtual |
Throws an exception if the specified index is invalid.
index | Zero base index of a child test. |
std::out_of_range | is index is < 0 or >= getChildTestCount(). |
|
pure virtual |
Return the number of test cases invoked by run().
The base unit of testing is the class TestCase. This method returns the number of TestCase objects invoked by the run() method.
Implemented in TestLeaf, TestComposite, TestDecorator, and RepeatedTest.
|
protectedpure virtual |
Returns the child test of the specified valid index.
index | Zero based valid index of the child test to return. |
NULL
. Implemented in TestSuite, TestRunner::WrappingSuite, TestLeaf, and TestDecorator.
|
virtual |
Finds the test with the specified name in the hierarchy.
testName | Name of the test to find. |
NULL
. std::invalid_argument | if no test named testName is found. |
|
virtual |
Finds the test with the specified name and its parents test.
testName | Name of the test to find. |
testPath | If the test is found, then all the tests traversed to access test are added to testPath, including this and test. |
true
if a test with the specified name is found, false
otherwise. Finds the specified test and its parents test.
test | Test to find. |
testPath | If the test is found, then all the tests traversed to access test are added to testPath, including this and test. |
true
if the specified test is found, false
otherwise.
|
virtual |
Returns the child test of the specified index.
This method test if the index is valid, then call doGetChildTestAt() if the index is valid. Otherwise std::out_of_range exception is thrown.
You should override doGetChildTestAt() method.
index | Zero based index of the child test to return. |
NULL
. std::out_of_range | is index is < 0 or >= getChildTestCount(). |
|
pure virtual |
Returns the number of direct child of the test.
Implemented in TestSuite, TestRunner::WrappingSuite, TestLeaf, and TestDecorator.
|
pure virtual |
Returns the test name.
Each test has a name. This name may be used to find the test in a suite or registry of tests.
Implemented in TestRunner::WrappingSuite, TestComposite, TestCase, TestDecorator, and TestCaseDecorator.
|
virtual |
|
pure virtual |
Run the test, collecting results.
Implemented in TestRunner::WrappingSuite, TestComposite, TestCase, TestSetUp, TestDecorator, and RepeatedTest.
Send comments to: CppUnit Developers |