diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-04-12 18:28:48 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-04-12 18:28:48 +0000 |
| commit | ed406a2966e62072fa6afaca8abc578db7c0c9fb (patch) | |
| tree | ab8d2ffb462c3c955b2e339e8cc19f1a6be8bd0f /include/cppunit/Test.h | |
| parent | fc9c76622b19adfcdebce682d9d49db8fb9336ef (diff) | |
| download | cppunit-ed406a2966e62072fa6afaca8abc578db7c0c9fb.tar.gz | |
Makefile.
Makefile.am: added examples/qt to tar ball release.
* TODO: heavily updated.
* contrib/msvc/CppUnit*.wwtpl: changed base class for unit test to TestFixture.
* include/cppunit/Test.h: removed toString() method. Not used by the framework
and source of confusions with getName().
Added getChildTestCount() and getChildTestAt(), introducing the composite pattern
at top level. Added utility methods findTest() and findTestPath().
* src/cppunit/Test.cpp: added. Implementation of new utility methods.
* include/cppunit/TestCase.h:
* src/cppunit/TestCase.cpp: inherits TestLeaf. Removed toString(), run(void) and
defaultResult(). Removed default constructor.
* src/cppunit/TestCase.cpp:
* src/cppunit/TestSuite.cpp: fixed some includes that used "" instead of <>.
* include/cppunit/TestComposite.h:
* src/cppunit/TestComposite.cpp: added. Common implementation of Test for composite
tests (TestSuite).
* include/cppunit/TestFailure.h:
* src/cppunit/TestFailure.cpp: removed toString().
* include/cppunit/TestLeaf.h:
* src/cppunit/TestLeaf.cpp: added. Common implementation of Test for single test
(TestCase).
* include/cppunit/TestListener.h: added TimingListener example to documentation.
* include/cppunit/TestPath.h:
* src/cppunit/TestPath.cpp: added. List of test traversed to access a test in the
test hierarchy.
* include/cppunit/TestRunner.h: added. Generic TestRunner.
* src/cppunit/TestRunner.cpp: moved to TextTestRunner.cpp. Added new implementation
of includecppunit/TestRunner.h.
* include/cppunit/TestSuite.h:
* src/cppunit/TestSuite.cpp: inherits TestComposite and implements new Test
interface. Removed toString().
* src/cppunit/TextTestRunner.cpp: moved from TestRunner.cpp. Implementation of
include/cppunit/ui/text/TestRunner.h.
* include/cppunit/extensions/RepeatedTest.h:
* src/cppunit/RepeatedTest.cpp: removed toString().
* include/cppunit/extensions/TestDecorator.h: inherits TestLeaf.
Removed toString()
* include/cppunit/XmlOutputter.h:
* src/cppunit/XmlOutputter.cpp:
* examples/cppunittest/XmlOutputterTest.cpp:
* examples/cppunittest/XmlOutputterTest.h: XML outputter now escape node content.
Add unit test for that bug (#540944). Added style sheet support. Modified
XML structure: failure message as its own element.
* src/msvc/testrunner/TestRunnerModel.h:
* src/msvc/testrunner/TestRunnerModel.cpp: used Test::findTest() to find a test
by name instead of using RTTI. Added toAnsiString() for convertion when
compiling as UNICODE.
* src/msvc/testrunner/TreeHierarchyDlg.h:
* src/msvc/testrunner/TreeHierarchyDlg.cpp: used new composite interface of Test
to explorer the test hierarchy instead of RTTI.
* examples/cppunittest/TestPathTest.h:
* examples/cppunittest/TestPathTest.cpp: added, unit tests for TestPath.
* examples/cppunittest/TestCaseTest.h:
* examples/cppunittest/TestCaseTest.cpp: added test for TestLeaf.
* examples/cppunittest/TestSuiteTest.h:
* examples/cppunittest/TestSuiteTest.cpp: added test for TestComposite and
new Test interface.
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; }; |
