diff options
| author | Steve M. Robbins <smr@sumost.ca> | 2001-07-15 03:18:06 +0000 |
|---|---|---|
| committer | Steve M. Robbins <smr@sumost.ca> | 2001-07-15 03:18:06 +0000 |
| commit | 08b4a5c444044db09dc5c668390e9f40663210ff (patch) | |
| tree | f94c3f33864a238e3edc29c6fc92ebff748e82fa /include/cppunit | |
| parent | 8cdfc19f2213bf1de4aee4bc5e799af49b6608d0 (diff) | |
| download | cppunit-08b4a5c444044db09dc5c668390e9f40663210ff.tar.gz | |
Added documentation.
Diffstat (limited to 'include/cppunit')
| -rw-r--r-- | include/cppunit/Exception.h | 67 | ||||
| -rw-r--r-- | include/cppunit/Test.h | 67 | ||||
| -rw-r--r-- | include/cppunit/TestCaller.h | 311 | ||||
| -rw-r--r-- | include/cppunit/TestCase.h | 200 | ||||
| -rw-r--r-- | include/cppunit/TestFailure.h | 70 | ||||
| -rw-r--r-- | include/cppunit/TestListener.h | 38 | ||||
| -rw-r--r-- | include/cppunit/TestSuite.h | 72 | ||||
| -rw-r--r-- | include/cppunit/extensions/RepeatedTest.h | 7 | ||||
| -rw-r--r-- | include/cppunit/extensions/TestDecorator.h | 22 |
9 files changed, 453 insertions, 401 deletions
diff --git a/include/cppunit/Exception.h b/include/cppunit/Exception.h index 1cf7548..8467c0a 100644 --- a/include/cppunit/Exception.h +++ b/include/cppunit/Exception.h @@ -6,57 +6,58 @@ namespace CppUnit { - /** - * Exception is an exception that serves - * descriptive strings through its what() method - * - */ - - class Exception : public std::exception - { +/*! \brief Exceptions thrown by failed assertions. + * + * Exception is an exception that serves + * descriptive strings through its what() method + */ +class Exception : public std::exception +{ +public: + + class Type + { public: - class Type - { - public: Type( std::string type ) : m_type ( type ) {} bool operator ==( const Type &other ) const { - return m_type == other.m_type; + return m_type == other.m_type; } - private: + private: const std::string m_type; - }; + }; - Exception( std::string message = "", - long lineNumber = UNKNOWNLINENUMBER, - std::string fileName = UNKNOWNFILENAME); - Exception (const Exception& other); + Exception( std::string message = "", + long lineNumber = UNKNOWNLINENUMBER, + std::string fileName = UNKNOWNFILENAME); + Exception (const Exception& other); - virtual ~Exception () throw(); + virtual ~Exception () throw(); - Exception& operator= (const Exception& other); + Exception& operator= (const Exception& other); - const char *what() const throw (); + const char *what() const throw (); - long lineNumber (); - std::string fileName (); + long lineNumber (); + std::string fileName (); - static const std::string UNKNOWNFILENAME; - static const long UNKNOWNLINENUMBER; + static const std::string UNKNOWNFILENAME; + static const long UNKNOWNLINENUMBER; - virtual Exception *clone() const; + virtual Exception *clone() const; + + virtual bool isInstanceOf( const Type &type ) const; - virtual bool isInstanceOf( const Type &type ) const; + static Type type(); - static Type type(); +private: + std::string m_message; + long m_lineNumber; + std::string m_fileName; +}; - private: - std::string m_message; - long m_lineNumber; - std::string m_fileName; - }; } // namespace CppUnit diff --git a/include/cppunit/Test.h b/include/cppunit/Test.h index 421e403..ca494ae 100644 --- a/include/cppunit/Test.h +++ b/include/cppunit/Test.h @@ -5,25 +5,54 @@ namespace CppUnit { - class TestResult; - - /** - * A Test can be run and collect its results. - * \see TestResult. - * - */ - class Test - { - public: - virtual ~Test () {}; - - virtual void run (TestResult *result) = 0; - virtual int countTestCases () const = 0; - virtual std::string toString () const = 0; - virtual std::string getName () const = 0; - - - }; +class TestResult; + +/*! \brief 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. + * + * \see TestCase + * \see TestSuite + */ +class 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; + + +}; } // namespace CppUnit diff --git a/include/cppunit/TestCaller.h b/include/cppunit/TestCaller.h index dee0b6d..96908d0 100644 --- a/include/cppunit/TestCaller.h +++ b/include/cppunit/TestCaller.h @@ -1,4 +1,4 @@ -#ifndef CPPUNIT_TESTCALLER_H +#ifndef CPPUNIT_TESTCALLER_H // -*- C++ -*- #define CPPUNIT_TESTCALLER_H #include <cppunit/TestCase.h> @@ -8,175 +8,180 @@ # include <cppunit/extensions/TypeInfoHelper.h> #endif + namespace CppUnit { - class NoExceptionExpected - { - private: +class NoExceptionExpected +{ +private: // Nobody must be able to construct an exception of this type. NoExceptionExpected(); - }; +}; - template<typename ExceptionType> - struct ExpectedExceptionTraits - { +template<typename ExceptionType> +struct ExpectedExceptionTraits +{ static void expectedException() { #if CPPUNIT_USE_TYPEINFO_NAME - std::string message( "Expected exception of type " ); - message += TypeInfoHelper::getClassName( typeid( ExceptionType ) ); - message += ", but got none"; + std::string message( "Expected exception of type " ); + message += TypeInfoHelper::getClassName( typeid( ExceptionType ) ); + message += ", but got none"; #else - std::string message( "Expected exception but got none" ); + std::string message( "Expected exception but got none" ); #endif - throw new Exception( message ); + throw new Exception( message ); } - }; +}; + - template<> - struct ExpectedExceptionTraits<NoExceptionExpected> - { +template<> +struct ExpectedExceptionTraits<NoExceptionExpected> +{ static void expectedException() { } - }; - - /** Provides access to a test case method. - * A test caller provides access to a test case method - * on a test case class. Test callers are useful when - * you want to run an individual test or add it to a - * suite. - * Test Callers invoke only one Test (i.e. test method) on one - * Fixture of a TestCase. - * - * Here is an example: - * \code - * class MathTest : public CppUnit::TestCase { - * ... - * public: - * void setUp (); - * void tearDown (); - * - * void testAdd (); - * void testSubtract (); - * }; - * - * CppUnit::Test *MathTest::suite () { - * CppUnit::TestSuite *suite = new CppUnit::TestSuite; - * - * suite->addTest (new CppUnit::TestCaller<MathTest> ("testAdd", testAdd)); - * return suite; - * } - * \endcode - * - * You can use a TestCaller to bind any test method on a TestCase - * class, as long as it accepts void and returns void. - * - * \see TestCase - */ - - template <typename Fixture, - typename ExpectedException = NoExceptionExpected> - class TestCaller : public TestCase - { - typedef void (Fixture::*TestMethod)(); +}; + + +/*! \brief Generate a test case from a fixture method. + * + * \b FIXME: rework this when class Fixture is implemented. + * A test caller provides access to a test case method + * on a test case class. Test callers are useful when + * you want to run an individual test or add it to a + * suite. + * Test Callers invoke only one Test (i.e. test method) on one + * Fixture of a TestCase. + * + * Here is an example: + * \code + * class MathTest : public CppUnit::TestCase { + * ... + * public: + * void setUp (); + * void tearDown (); + * + * void testAdd (); + * void testSubtract (); + * }; + * + * CppUnit::Test *MathTest::suite () { + * CppUnit::TestSuite *suite = new CppUnit::TestSuite; + * + * suite->addTest (new CppUnit::TestCaller<MathTest> ("testAdd", testAdd)); + * return suite; + * } + * \endcode + * + * You can use a TestCaller to bind any test method on a TestCase + * class, as long as it accepts void and returns void. + * + * \see TestCase + */ + +template <typename Fixture, + typename ExpectedException = NoExceptionExpected> +class TestCaller : public TestCase +{ + typedef void (Fixture::*TestMethod)(); - public: - /** - * Constructor for TestCaller. This constructor builds a new Fixture - * instance owned by the TestCaller. - * \param name name of this TestCaller - * \param test the method this TestCaller calls in runTest() - **/ - TestCaller (std::string name, TestMethod test) : - TestCase (name), - m_ownFixture(true), - m_fixture (new Fixture ()), - m_test (test) - {} - - /** - * Constructor for TestCaller. - * This constructor does not create a new Fixture instance but accepts - * an existing one as parameter. The TestCaller will not own the - * Fixture object. - * \param name name of this TestCaller - * \param test the method this TestCaller calls in runTest() - * \param fixture the Fixture to invoke the test method on. - **/ - TestCaller(std::string name, TestMethod test, Fixture& fixture) : - TestCase (name), - m_ownFixture(false), - m_fixture (&fixture), - m_test (test) - {} - - /** - * Constructor for TestCaller. - * This constructor does not create a new Fixture instance but accepts - * an existing one as parameter. The TestCaller will own the - * Fixture object and delete it in its destructor. - * \param name name of this TestCaller - * \param test the method this TestCaller calls in runTest() - * \param fixture the Fixture to invoke the test method on. - **/ - TestCaller(std::string name, TestMethod test, Fixture* fixture) : - TestCase (name), - m_ownFixture(true), - m_fixture (fixture), - m_test (test) - {} - - ~TestCaller() { - if (m_ownFixture) { - if (m_fixture) { - delete m_fixture; - m_fixture = NULL; - } - } - } - - protected: - void runTest () - { - try - { - (m_fixture->*m_test)(); - } - catch ( ExpectedException & ) - { - return; - } - - ExpectedExceptionTraits<ExpectedException>::expectedException(); - } - - void setUp () - { - m_fixture->setUp (); - } - - void tearDown () - { - m_fixture->tearDown (); - } - - std::string toString () const - { - return "TestCaller " + getName(); - } - - private: - TestCaller (const TestCaller& other); - TestCaller& operator= (const TestCaller& other); - - private: - bool m_ownFixture; - Fixture* m_fixture; - TestMethod m_test; - - }; +public: + /** + * Constructor for TestCaller. This constructor builds a new Fixture + * instance owned by the TestCaller. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + **/ + TestCaller (std::string name, TestMethod test) : + TestCase (name), + m_ownFixture(true), + m_fixture (new Fixture ()), + m_test (test) + {} + + /** + * Constructor for TestCaller. + * This constructor does not create a new Fixture instance but accepts + * an existing one as parameter. The TestCaller will not own the + * Fixture object. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + * \param fixture the Fixture to invoke the test method on. + **/ + TestCaller(std::string name, TestMethod test, Fixture& fixture) : + TestCase (name), + m_ownFixture(false), + m_fixture (&fixture), + m_test (test) + {} + + /** + * Constructor for TestCaller. + * This constructor does not create a new Fixture instance but accepts + * an existing one as parameter. The TestCaller will own the + * Fixture object and delete it in its destructor. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + * \param fixture the Fixture to invoke the test method on. + **/ + TestCaller(std::string name, TestMethod test, Fixture* fixture) : + TestCase (name), + m_ownFixture(true), + m_fixture (fixture), + m_test (test) + {} + + ~TestCaller() { + if (m_ownFixture) { + if (m_fixture) { + delete m_fixture; + m_fixture = NULL; + } + } + } + +protected: + void runTest () + { + try { + (m_fixture->*m_test)(); + } + catch ( ExpectedException & ) { + return; + } + + ExpectedExceptionTraits<ExpectedException>::expectedException(); + } + + void setUp () + { + m_fixture->setUp (); + } + + void tearDown () + { + m_fixture->tearDown (); + } + + std::string toString () const + { + return "TestCaller " + getName(); + } + +private: + TestCaller (const TestCaller& other); + TestCaller& operator= (const TestCaller& other); + +private: + bool m_ownFixture; + Fixture* m_fixture; + TestMethod m_test; + +}; + + } // namespace CppUnit diff --git a/include/cppunit/TestCase.h b/include/cppunit/TestCase.h index dc85e7a..30124d8 100644 --- a/include/cppunit/TestCase.h +++ b/include/cppunit/TestCase.h @@ -7,106 +7,122 @@ namespace CppUnit { - class TestResult; +class TestResult; - /** - * A test case defines the fixture to run multiple tests. - * To define a test case - * do the following: - * - implement a subclass of TestCase - * - the fixture is defined by instance variables - * - initialize the fixture state by overriding setUp - * (i.e. construct the instance variables of the fixture) - * - clean-up after a test by overriding tearDown. - * - * Each test runs in its own fixture so there - * can be no side effects among test runs. - * Here is an example: - * - * \code - * class MathTest : public TestCase { - * protected: int m_value1; - * protected: int m_value2; - * - * public: MathTest (string name) - * : TestCase (name) { - * } - * - * protected: void setUp () { - * m_value1 = 2; - * m_value2 = 3; - * } - * } - * \endcode - * - * For each test implement a method which interacts - * with the fixture. Verify the expected results with assertions specified - * by calling CPPUNIT_ASSERT on the expression you want to test: - * - * \code - * protected: void testAdd () { - * int result = value1 + value2; - * CPPUNIT_ASSERT (result == 5); - * } - * \endcode - * - * Once the methods are defined you can run them. To do this, use - * a TestCaller. - * - * \code - * Test *test = new TestCaller<MathTest>("testAdd", MathTest::testAdd); - * test->run (); - * \endcode - * - * - * The tests to be run can be collected into a TestSuite. - * - * \code - * public: static TestSuite *MathTest::suite () { - * TestSuite *suiteOfTests = new TestSuite; - * suiteOfTests->addTest(new TestCaller<MathTest>( - * "testAdd", testAdd)); - * suiteOfTests->addTest(new TestCaller<MathTest>( - * "testDivideByZero", testDivideByZero)); - * return suiteOfTests; - * } - * \endcode - * - * - * \see TestResult - * \see TestSuite - * \see TestCaller - * - */ - class TestCase : public Test - { - public: - TestCase (); - TestCase (std::string Name); - ~TestCase (); +/*! \brief A single test object. + * + * This class is used to implement a simple test case: define a subclass + * that overrides the runTest method. + * + */ - virtual void run (TestResult *result); - virtual TestResult *run (); - virtual int countTestCases () const; - std::string getName () const; - std::string toString () const; +/* FIXME: this documentation belongs to proposed class Fixture. + * + * A test case defines the fixture to run multiple tests. + * To define a test case + * do the following: + * - implement a subclass of TestCase + * - the fixture is defined by instance variables + * - initialize the fixture state by overriding setUp + * (i.e. construct the instance variables of the fixture) + * - clean-up after a test by overriding tearDown. + * + * Each test runs in its own fixture so there + * can be no side effects among test runs. + * Here is an example: + * + * \code + * class MathTest : public TestCase { + * protected: int m_value1; + * protected: int m_value2; + * + * public: MathTest (string name) + * : TestCase (name) { + * } + * + * protected: void setUp () { + * m_value1 = 2; + * m_value2 = 3; + * } + * } + * \endcode + * + * For each test implement a method which interacts + * with the fixture. Verify the expected results with assertions specified + * by calling CPPUNIT_ASSERT on the expression you want to test: + * + * \code + * protected: void testAdd () { + * int result = value1 + value2; + * CPPUNIT_ASSERT (result == 5); + * } + * \endcode + * + * Once the methods are defined you can run them. To do this, use + * a TestCaller. + * + * \code + * Test *test = new TestCaller<MathTest>("testAdd", MathTest::testAdd); + * test->run (); + * \endcode + * + * + * The tests to be run can be collected into a TestSuite. + * + * \code + * public: static TestSuite *MathTest::suite () { + * TestSuite *suiteOfTests = new TestSuite; + * suiteOfTests->addTest(new TestCaller<MathTest>( + * "testAdd", testAdd)); + * suiteOfTests->addTest(new TestCaller<MathTest>( + * "testDivideByZero", testDivideByZero)); + * return suiteOfTests; + * } + * \endcode + * + * + * \see TestResult + * \see TestSuite + * \see TestCaller + * + */ - virtual void setUp (); - virtual void tearDown (); +class TestCase : public Test +{ +public: - protected: - virtual void runTest (); + TestCase (std::string Name); + //! \internal + TestCase (); + ~TestCase (); - TestResult *defaultResult (); + virtual void run (TestResult *result); + virtual int countTestCases () const; + std::string getName () const; + std::string toString () const; + + //! FIXME: what is this for? + virtual TestResult *run (); + - private: - TestCase (const TestCase& other); - TestCase& operator= (const TestCase& other); + virtual void setUp (); + virtual void tearDown (); + +protected: + //! FIXME: this should probably be pure virtual. + virtual void runTest (); - private: - const std::string m_name; - }; + //! Create TestResult for the run(void) method. + TestResult *defaultResult (); + +private: + TestCase (const TestCase& other); + TestCase& operator= (const TestCase& other); + +private: + const std::string m_name; +}; } // namespace CppUnit diff --git a/include/cppunit/TestFailure.h b/include/cppunit/TestFailure.h index f8dae91..bb2c226 100644 --- a/include/cppunit/TestFailure.h +++ b/include/cppunit/TestFailure.h @@ -1,56 +1,52 @@ -#ifndef CPPUNIT_TESTFAILURE_H +#ifndef CPPUNIT_TESTFAILURE_H // -*- C++ -*- #define CPPUNIT_TESTFAILURE_H #include <string> namespace CppUnit { - class Test; - class Exception; +class Test; +class Exception; - /** - * A TestFailure collects a failed test together with - * the caught exception. - * - * TestFailure assumes lifetime control for any exception - * passed to it. The lifetime of tests is handled by - * their TestSuite (if they have been added to one) or - * whomever creates them. - * - * see TestResult - * see TestSuite - * - */ - class TestFailure - { - public: - TestFailure (Test *failedTest, Exception *thrownException); - ~TestFailure (); +/*! \brief Record of a failed test execution. + * + * A TestFailure collects a failed test together with + * the caught exception. + * + * TestFailure assumes lifetime control for any exception + * passed to it. + */ +class TestFailure +{ +public: + TestFailure (Test *failedTest, Exception *thrownException); + ~TestFailure (); - Test* failedTest (); + Test* failedTest (); - Exception* thrownException (); + Exception* thrownException (); + + std::string toString () const; - std::string toString () const; +protected: + Test *m_failedTest; + Exception *m_thrownException; - protected: - Test *m_failedTest; - Exception *m_thrownException; +private: + TestFailure (const TestFailure& other); + TestFailure& operator= (const TestFailure& other); +}; - private: - TestFailure (const TestFailure& other); - TestFailure& operator= (const TestFailure& other); - }; +/// Gets the failed test. +inline Test *TestFailure::failedTest () +{ return m_failedTest; } - /// Gets the failed test. - inline Test *TestFailure::failedTest () - { return m_failedTest; } +/// Gets the thrown exception. +inline Exception *TestFailure::thrownException () +{ return m_thrownException; } - /// Gets the thrown exception. - inline Exception *TestFailure::thrownException () - { return m_thrownException; } } // namespace CppUnit diff --git a/include/cppunit/TestListener.h b/include/cppunit/TestListener.h index 31fd8ea..15e939b 100644 --- a/include/cppunit/TestListener.h +++ b/include/cppunit/TestListener.h @@ -1,26 +1,28 @@ -#ifndef CPPUNIT_TESTLISTENER_H +#ifndef CPPUNIT_TESTLISTENER_H // -*- C++ -*- #define CPPUNIT_TESTLISTENER_H -namespace CppUnit { - - class Exception; - class Test; +namespace CppUnit { - /** - * A Listener for test progress - * \see TestResult - */ - class TestListener - { - public: - virtual ~TestListener() {} +class Exception; +class Test; + + +/*! \brief A listener for test progress. + * + * \see TestResult + */ +class TestListener +{ +public: + virtual ~TestListener() {} + + virtual void startTest( Test *test ) {} + virtual void addError( Test *test, Exception *e ) {} + virtual void addFailure( Test *test, Exception *e ) {} + virtual void endTest( Test *test ) {} +}; - virtual void addError( Test *test, Exception *e ) {} - virtual void addFailure( Test *test, Exception *e ) {} - virtual void startTest( Test *test ) {} - virtual void endTest( Test *test ) {} - }; } // namespace CppUnit diff --git a/include/cppunit/TestSuite.h b/include/cppunit/TestSuite.h index f61cbf6..a3cfc65 100644 --- a/include/cppunit/TestSuite.h +++ b/include/cppunit/TestSuite.h @@ -1,4 +1,4 @@ -#ifndef CPPUNIT_TESTSUITE_H +#ifndef CPPUNIT_TESTSUITE_H // -*- C++ -*- #define CPPUNIT_TESTSUITE_H #include <vector> @@ -7,51 +7,53 @@ namespace CppUnit { - class TestResult; - - /** - * A TestSuite is a Composite of Tests. - * It runs a collection of test cases. Here is an example. - * \code - * CppUnit::TestSuite *suite= new CppUnit::TestSuite(); - * suite->addTest(new CppUnit::TestCaller<MathTest> ( - * "testAdd", testAdd)); - * suite->addTest(new CppUnit::TestCaller<MathTest> ( - * "testDivideByZero", testDivideByZero)); - * \endcode - * Note that TestSuites assume lifetime - * control for any tests added to them. - * - * TestSuites do not register themselves in the TestRegistry. - * \see Test - * \see TestCaller - */ - - - class TestSuite : public Test - { - public: - TestSuite (std::string name = ""); - ~TestSuite (); +class TestResult; + +/*! \brief A Composite of Tests. + * + * It runs a collection of test cases. Here is an example. + * \code + * CppUnit::TestSuite *suite= new CppUnit::TestSuite(); + * suite->addTest(new CppUnit::TestCaller<MathTest> ( + * "testAdd", testAdd)); + * suite->addTest(new CppUnit::TestCaller<MathTest> ( + * "testDivideByZero", testDivideByZero)); + * \endcode + * Note that TestSuites assume lifetime + * control for any tests added to them. + * + * TestSuites do not register themselves in the TestRegistry. + * \see Test + * \see TestCaller + */ + + +class TestSuite : public Test +{ +public: + TestSuite (std::string name = ""); + ~TestSuite (); void run (TestResult *result); int countTestCases () const; - void addTest (Test *test); std::string getName () const; std::string toString () const; + void addTest (Test *test); const std::vector<Test *> & getTests() const; virtual void deleteContents (); - private: - TestSuite (const TestSuite& other); - TestSuite& operator= (const TestSuite& other); +private: + TestSuite (const TestSuite& other); + TestSuite& operator= (const TestSuite& other); + +private: + std::vector<Test *> m_tests; + const std::string m_name; +}; + - private: - std::vector<Test *> m_tests; - const std::string m_name; - }; } // namespace CppUnit #endif // CPPUNIT_TESTSUITE_H diff --git a/include/cppunit/extensions/RepeatedTest.h b/include/cppunit/extensions/RepeatedTest.h index 7a68e88..b28deeb 100644 --- a/include/cppunit/extensions/RepeatedTest.h +++ b/include/cppunit/extensions/RepeatedTest.h @@ -9,10 +9,9 @@ class Test; class TestResult; -/* - * A decorator that runs a test repeatedly. - * Does not assume ownership of the test it decorates +/*! \brief Decorator that runs a test repeatedly. * + * Does not assume ownership of the test it decorates */ class RepeatedTest : public TestDecorator { @@ -22,9 +21,9 @@ public: TestDecorator( test ), m_timesRepeat(timesRepeat) {} + void run( TestResult *result ); int countTestCases(); std::string toString(); - void run( TestResult *result ); private: RepeatedTest( const RepeatedTest & ); diff --git a/include/cppunit/extensions/TestDecorator.h b/include/cppunit/extensions/TestDecorator.h index caf08a3..2a6b9d7 100644 --- a/include/cppunit/extensions/TestDecorator.h +++ b/include/cppunit/extensions/TestDecorator.h @@ -7,30 +7,32 @@ namespace CppUnit { class TestResult; -/* - * A Decorator for Tests + +/*! \brief Decorator for Tests. * - * Does not assume ownership of the test it decorates + * TestDecorator provides an alternate means to extend functionality + * of a test class without subclassing the test. Instead, one can + * subclass the decorater and use it to wrap the test class. * + * Does not assume ownership of the test it decorates */ - class TestDecorator : public Test { public: - TestDecorator (Test *test); - ~TestDecorator (); + TestDecorator (Test *test); + ~TestDecorator (); - int countTestCases () const; void run (TestResult *result); - std::string toString () const; + int countTestCases () const; std::string getName () const; + std::string toString () const; protected: Test *m_test; private: - TestDecorator( const TestDecorator &); - void operator =( const TestDecorator & ); + TestDecorator( const TestDecorator &); + void operator =( const TestDecorator & ); }; |
