4
#include <cppunit/Portability.h>
13
/*! \brief Base class for all test objects.
14
* \ingroup BrowsingCollectedTestResult
16
* All test objects should be a subclass of Test. Some test objects,
17
* TestCase for example, represent one individual test. Other test
18
* objects, such as TestSuite, are comprised of several tests.
20
* When a Test is run, the result is collected by a TestResult object.
25
class CPPUNIT_API Test
30
/*! \brief Run the test, collecting results.
32
virtual void run( TestResult *result ) =0;
34
/*! \brief Return the number of test cases invoked by run().
36
* The base unit of testing is the class TestCase. This
37
* method returns the number of TestCase objects invoked by
40
virtual int countTestCases () const =0;
42
/*! \brief Returns the number of direct child of the test.
44
virtual int getChildTestCount() const =0;
46
/*! \brief Returns the child test of the specified index.
48
* This method test if the index is valid, then call doGetChildTestAt() if
49
* the index is valid. Otherwise std::out_of_range exception is thrown.
51
* You should override doGetChildTestAt() method.
53
* \param index Zero based index of the child test to return.
54
* \return Pointer on the test. Never \c NULL.
55
* \exception std::out_of_range is \a index is < 0 or >= getChildTestCount().
57
virtual Test *getChildTestAt( int index ) const;
59
/*! \brief Returns the test name.
61
* Each test has a name. This name may be used to find the
62
* test in a suite or registry of tests.
64
virtual std::string getName () const =0;
66
/*! \brief Finds the test with the specified name and its parents test.
67
* \param testName Name of the test to find.
68
* \param testPath If the test is found, then all the tests traversed to access
69
* \a test are added to \a testPath, including \c this and \a test.
70
* \return \c true if a test with the specified name is found, \c false otherwise.
72
virtual bool findTestPath( const std::string &testName,
73
TestPath &testPath ) const;
75
/*! \brief Finds the specified test and its parents test.
76
* \param test Test to find.
77
* \param testPath If the test is found, then all the tests traversed to access
78
* \a test are added to \a testPath, including \c this and \a test.
79
* \return \c true if the specified test is found, \c false otherwise.
81
virtual bool findTestPath( const Test *test,
82
TestPath &testPath ) const;
84
/*! \brief Finds the test with the specified name in the hierarchy.
85
* \param testName Name of the test to find.
86
* \return Pointer on the first test found that is named \a testName. Never \c NULL.
87
* \exception std::invalid_argument if no test named \a testName is found.
89
virtual Test *findTest( const std::string &testName ) const;
91
/*! \brief Resolved the specified test path with this test acting as 'root'.
92
* \param testPath Test path string to resolve.
93
* \return Resolved TestPath.
94
* \exception std::invalid_argument if \a testPath could not be resolved.
97
virtual TestPath resolveTestPath( const std::string &testPath ) const;
100
/*! Throws an exception if the specified index is invalid.
101
* \param index Zero base index of a child test.
102
* \exception std::out_of_range is \a index is < 0 or >= getChildTestCount().
104
virtual void checkIsValidIndex( int index ) const;
106
/*! \brief Returns the child test of the specified valid index.
107
* \param index Zero based valid index of the child test to return.
108
* \return Pointer on the test. Never \c NULL.
110
virtual Test *doGetChildTestAt( int index ) const =0;
116
#endif // CPPUNIT_TEST_H