diff options
Diffstat (limited to 'include/cppunit/Test.h')
| -rw-r--r-- | include/cppunit/Test.h | 107 |
1 files changed, 78 insertions, 29 deletions
diff --git a/include/cppunit/Test.h b/include/cppunit/Test.h index 2ee2a48..dde4958 100644 --- a/include/cppunit/Test.h +++ b/include/cppunit/Test.h @@ -7,6 +7,7 @@ namespace CppUnit { class TestResult; +class TestPath; /*! \brief Base class for all test objects. * \ingroup BrowsingCollectedTestResult @@ -23,37 +24,85 @@ class TestResult; class CPPUNIT_API Test { public: - virtual ~Test () {}; - - /*! \brief Run the test, collecting results. - */ - virtual void run (TestResult *result) = 0; - - /*! \brief 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. - */ - virtual int countTestCases () const = 0; - - /*! \brief 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. - */ - virtual std::string getName () const = 0; - - /*! \brief Description of the test, for diagnostic output. - * - * The test description will typically include the test name, - * but may have additional description. For example, a test - * suite named <tt>complex_add</tt> may be described as - * <tt>suite complex_add</tt>. - */ - virtual std::string toString () const = 0; + virtual ~Test() {}; + /*! \brief Run the test, collecting results. + */ + virtual void run( TestResult *result ) =0; + /*! \brief 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. + */ + virtual int countTestCases () const =0; + + /*! \brief Returns the number of direct child of the test. + */ + virtual int getChildTestCount() const =0; + + /*! \brief 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. + */ + virtual std::string getName () const =0; + + /*! \brief 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. + * + * \param index Zero based index of the child test to return. + * \return Pointer on the test. Never \c NULL. + * \exception std::out_of_range is \a index is < 0 or >= getChildTestCount(). + */ + virtual Test *getChildTestAt( int index ) const; + + /*! \brief Finds the test with the specified name and its parents test. + * \param testName Name of the test to find. + * \return \c true if a test with the specified name is found, \c false otherwise. + */ + virtual bool findTestPath( const std::string &testName, + TestPath &testPath ); + + /*! \brief Finds the specified test and its parents test. + * \param test Test to find. + * \return \c true if the specified test is found, \c false otherwise. + */ + virtual bool findTestPath( const Test *test, + TestPath &testPath ); + + /*! \brief Finds the test with the specified name in the hierarchy. + * \param testName Name of the test to find. + * \return Pointer on the first test found that is named \a testName. Never \c NULL. + * \exception std::invalid_argument if no test named \a testName is found. + */ + virtual Test *findTest( const std::string &testName ) const; + + /*! \brief Resolved the specified test path with this test acting as 'root'. + * \param testPath Test path string to resolve. + * \return Resolved TestPath. + * \exception std::invalid_argument if \a testPath could not be resolved. + * \see TestPath. + */ + virtual TestPath resolveTestPath( const std::string &testPath ); + +protected: + /*! Throws an exception if the specified index is invalid. + * \param Zero base index of a child test. + * \exception std::out_of_range is \a index is < 0 or >= getChildTestCount(). + */ + virtual void checkIsValidIndex( int index ) const; + + /*! \brief Returns the child test of the specified valid index. + * \param index Zero based valid index of the child test to return. + * \return Pointer on the test. Never \c NULL. + */ + virtual Test *doGetChildTestAt( int index ) const =0; }; |
