diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-08-29 18:27:07 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-08-29 18:27:07 +0000 |
| commit | 40669673029364275f58207549f91b8390215ec7 (patch) | |
| tree | 64f006dc0eb826c11c5b85bc24d963b1811ba245 /include/cppunit | |
| parent | eb3575761c12af9822403fcf25b6930150fb6890 (diff) | |
| download | cppunit-40669673029364275f58207549f91b8390215ec7.tar.gz | |
Include/cppunit/CompilerOutputter.
include/cppunit/CompilerOutputter.h:
* include/cppunit/Exception.h:
* include/cppunit/Protector.h:
* include/cppunit/TestListener.h:
* include/cppunit/TestPath.h:
* include/cppunit/TestResult.h:
* include/cppunit/TestRunner.h:
* include/cppunit/XmlOutputter.h:
* include/cppunit/plugin/DynamicLibraryManager.h:
* include/cppunit/plugin/PlugInManager.h:
* include/cppunit/plugin/PlugInParameters.h:
* include/cppunit/TestPlugIn.h:
* src/cppunit/DefaultProtector.h:
* src/cppunit/ProtectorChain.h:
* src/cppunit/ProtectorContext.h:
* src/cppunit/TestCase.cpp:
* src/cppunit/TestResult.cpp: fixed a dew documentation bugs.
* include/cppunit/TestResult.h:
* src/cppunit/TestResult.cpp: moved documentation to header.
Diffstat (limited to 'include/cppunit')
| -rw-r--r-- | include/cppunit/CompilerOutputter.h | 6 | ||||
| -rw-r--r-- | include/cppunit/Exception.h | 4 | ||||
| -rw-r--r-- | include/cppunit/Protector.h | 8 | ||||
| -rw-r--r-- | include/cppunit/TestListener.h | 10 | ||||
| -rw-r--r-- | include/cppunit/TestPath.h | 38 | ||||
| -rw-r--r-- | include/cppunit/TestResult.h | 46 | ||||
| -rw-r--r-- | include/cppunit/TestRunner.h | 6 | ||||
| -rw-r--r-- | include/cppunit/XmlOutputter.h | 18 | ||||
| -rw-r--r-- | include/cppunit/plugin/DynamicLibraryManager.h | 4 | ||||
| -rw-r--r-- | include/cppunit/plugin/PlugInManager.h | 12 | ||||
| -rw-r--r-- | include/cppunit/plugin/PlugInParameters.h | 5 | ||||
| -rw-r--r-- | include/cppunit/plugin/TestPlugIn.h | 20 |
12 files changed, 115 insertions, 62 deletions
diff --git a/include/cppunit/CompilerOutputter.h b/include/cppunit/CompilerOutputter.h index 04be58f..e5ca0b3 100644 --- a/include/cppunit/CompilerOutputter.h +++ b/include/cppunit/CompilerOutputter.h @@ -55,7 +55,7 @@ class TestResultCollector; class CPPUNIT_API CompilerOutputter : public Outputter { public: - /*! Constructs a CompilerOutputter object. + /*! \brief Constructs a CompilerOutputter object. * \param result Result of the test run. * \param stream Stream used to output test result. * \param locationFormat Error location format used by your compiler. Default @@ -70,7 +70,7 @@ public: /// Destructor. virtual ~CompilerOutputter(); - /*! Sets the error location format. + /*! \brief Sets the error location format. * * Indicates the format used to report location of failed assertion. This format should * match the one used by your compiler. @@ -95,7 +95,7 @@ public: */ void setLocationFormat( const std::string &locationFormat ); - /*! Creates an instance of an outputter that matches your current compiler. + /*! \brief Creates an instance of an outputter that matches your current compiler. * \deprecated This class is specialized through parameterization instead of subclassing... * Use CompilerOutputter::CompilerOutputter instead. */ diff --git a/include/cppunit/Exception.h b/include/cppunit/Exception.h index 09e3198..bf5fcac 100644 --- a/include/cppunit/Exception.h +++ b/include/cppunit/Exception.h @@ -19,7 +19,7 @@ CPPUNIT_NS_BEGIN class CPPUNIT_API Exception : public std::exception { public: - /*! Constructs the exception with the specified message and source location. + /*! \brief Constructs the exception with the specified message and source location. * \param message Message associated to the exception. * \param sourceLine Source location related to the exception. */ @@ -35,7 +35,7 @@ public: std::string fileName ); #endif - /*! Constructs a copy of an exception. + /*! \brief Constructs a copy of an exception. * \param other Exception to copy. */ Exception( const Exception &other ); diff --git a/include/cppunit/Protector.h b/include/cppunit/Protector.h index f854878..ae2beda 100644 --- a/include/cppunit/Protector.h +++ b/include/cppunit/Protector.h @@ -68,11 +68,19 @@ protected: }; +/*! \brief Scoped protector push to TestResult. + * + * Adds the specified Protector to the specified TestResult for the object + * life-time. + */ class CPPUNIT_API ProtectorGuard { public: + /// Pushes the specified protector. ProtectorGuard( TestResult *result, Protector *protector ); + + /// Pops the protector. ~ProtectorGuard(); private: diff --git a/include/cppunit/TestListener.h b/include/cppunit/TestListener.h index d110b30..cb256fa 100644 --- a/include/cppunit/TestListener.h +++ b/include/cppunit/TestListener.h @@ -99,7 +99,7 @@ public: /// Called when just before a TestCase is run. virtual void startTest( Test *test ) {} - /*! Called when a failure occurs while running a test. + /*! \brief Called when a failure occurs while running a test. * \see TestFailure. * \warning \a failure is a temporary object that is destroyed after the * method call. Use TestFailure::clone() to create a duplicate. @@ -109,15 +109,15 @@ public: /// Called just after a TestCase was run (even if a failure occured). virtual void endTest( Test *test ) {} - /*! Called by a TestComposite just before running its child tests. + /*! \brief Called by a TestComposite just before running its child tests. */ virtual void startSuite( Test *suite ) {} - /*! Called by a TestComposite after running its child tests. + /*! \brief Called by a TestComposite after running its child tests. */ virtual void endSuite( Test *suite ) {} - /*! Called by a TestRunner before running the test. + /*! \brief Called by a TestRunner before running the test. * * You can use this to do some global initialisation. A listener * could also use to output a 'prolog' to the test run. @@ -128,7 +128,7 @@ public: virtual void startTestRun( Test *test, TestResult *eventManager ) {} - /*! Called by a TestRunner after running the test. + /*! \brief Called by a TestRunner after running the test. * * TextTestProgressListener use this to emit a line break. You can also use this * to do some global uninitialisation. diff --git a/include/cppunit/TestPath.h b/include/cppunit/TestPath.h index 63dbae4..12e9de1 100644 --- a/include/cppunit/TestPath.h +++ b/include/cppunit/TestPath.h @@ -33,19 +33,19 @@ class Test; class CPPUNIT_API TestPath { public: - /*! Constructs an invalid path. + /*! \brief Constructs an invalid path. * * The path is invalid until a test is added with add(). */ TestPath(); - /*! Constructs a valid path. + /*! \brief Constructs a valid path. * * \param root Test to add. */ TestPath( Test *root ); - /*! Constructs a path using a slice of another path. + /*! \brief Constructs a path using a slice of another path. * \param otherPath Path the test are copied from. * \param indexFirst Zero based index of the first test to copy. Adjusted to be in valid * range. \a count is adjusted with \a indexFirst. @@ -56,7 +56,7 @@ public: int indexFirst, int count = -1 ); - /*! Resolves a path from a string returned by toString(). + /*! \brief Resolves a path from a string returned by toString(). * * If \a pathAsString is an absolute path (begins with '/'), then the first test name * of the path must be the name of \a searchRoot. Otherwise, \a pathAsString is a @@ -74,36 +74,36 @@ public: TestPath( Test *searchRoot, const std::string &pathAsString ); - /*! Copy constructor. + /*! \brief Copy constructor. * \param other Object to copy. */ TestPath( const TestPath &other ); virtual ~TestPath(); - /*! Tests if the path contains at least one test. + /*! \brief Tests if the path contains at least one test. * \return \c true if the path contains at least one test, otherwise returns \c false. */ virtual bool isValid() const; - /*! Adds a test to the path. + /*! \brief Adds a test to the path. * \param test Pointer on the test to add. Must not be \c NULL. */ virtual void add( Test *test ); - /*! Adds all the tests of the specified path. + /*! \brief Adds all the tests of the specified path. * \param path Path that contains the test to add. */ virtual void add( const TestPath &path ); - /*! Inserts a test at the specified index. + /*! \brief Inserts a test at the specified index. * \param test Pointer on the test to insert. Must not be \c NULL. * \param index Zero based index indicating where the test is inserted. * \exception std::out_of_range is \a index < 0 or \a index > getTestCount(). */ virtual void insert( Test *test, int index ); - /*! Inserts all the tests at the specified path at a given index. + /*! \brief Inserts all the tests at the specified path at a given index. * \param path Path that contains the test to insert. * \param index Zero based index indicating where the tests are inserted. * \exception std::out_of_range is \a index < 0 or \a index > getTestCount(), and @@ -111,30 +111,30 @@ public: */ virtual void insert( const TestPath &path, int index ); - /*! Removes all the test from the path. + /*! \brief Removes all the test from the path. * * The path becomes invalid after this call. */ virtual void removeTests(); - /*! Removes the test at the specified index of the path. + /*! \brief Removes the test at the specified index of the path. * \param index Zero based index of the test to remove. * \exception std::out_of_range is \a index < 0 or \a index >= getTestCount(). */ virtual void removeTest( int index ); - /*! Removes the last test. + /*! \brief Removes the last test. * \exception std::out_of_range is the path is invalid. * \see isValid(). */ virtual void up(); - /*! Returns the number of tests in the path. + /*! \brief Returns the number of tests in the path. * \return Number of tests in the path. */ virtual int getTestCount() const; - /*! Returns the test of the specified index. + /*! \brief Returns the test of the specified index. * \param index Zero based index of the test to return. * \return Pointer on the test at index \a index. Never \c NULL. * \exception std::out_of_range is \a index < 0 or \a index >= getTestCount(). @@ -159,14 +159,14 @@ public: */ virtual std::string toString() const; - /*! Assignment operator. + /*! \brief Assignment operator. * \param other Object to copy. * \return This object. */ TestPath &operator =( const TestPath &other ); protected: - /*! Checks that the specified test index is within valid range. + /*! \brief Checks that the specified test index is within valid range. * \param index Zero based index to check. * \exception std::out_of_range is \a index < 0 or \a index >= getTestCount(). */ @@ -175,7 +175,7 @@ protected: /// A list of test names. typedef CppUnitDeque<std::string> PathTestNames; - /*! Splits a path string into its test name components. + /*! \brief Splits a path string into its test name components. * \param pathAsString Path string created with toString(). * \param testNames Test name components are added to that container. * \return \c true if the path is relative (does not begin with '/'), \c false @@ -184,7 +184,7 @@ protected: bool splitPathString( const std::string &pathAsString, PathTestNames &testNames ); - /*! Finds the actual root of a path string and get the path string name components. + /*! \brief Finds the actual root of a path string and get the path string name components. * \param searchRoot Test used as root if the path string is absolute, or to search * the root test if the path string is relative. * \param pathAsString Path string. May be absolute or relative. diff --git a/include/cppunit/TestResult.h b/include/cppunit/TestResult.h index 4388847..ff3243b 100644 --- a/include/cppunit/TestResult.h +++ b/include/cppunit/TestResult.h @@ -50,36 +50,78 @@ class TestListener; class CPPUNIT_API TestResult : protected SynchronizedObject { public: + /// Construct a TestResult TestResult( SynchronizationObject *syncObject = 0 ); + + /// Destroys a test result virtual ~TestResult(); virtual void addListener( TestListener *listener ); virtual void removeListener( TestListener *listener ); - - virtual void reset(); + + /// Stop testing virtual void stop(); + /// Returns whether testing should be stopped virtual bool shouldStop() const; + /// Informs TestListener that a test will be started. virtual void startTest( Test *test ); + + /*! \brief Adds an error to the list of errors. + * The passed in exception + * caused the error + */ virtual void addError( Test *test, Exception *e ); + + /*! \brief Adds a failure to the list of failures. The passed in exception + * caused the failure. + */ virtual void addFailure( Test *test, Exception *e ); + + /// Informs TestListener that a test was completed. virtual void endTest( Test *test ); + /// Informs TestListener that a test suite will be started. virtual void startSuite( Test *test ); + + /// Informs TestListener that a test suite was completed. virtual void endSuite( Test *test ); + /*! \brief Run the specified test. + * + * Calls startTestRun(), test->run(this), and finally endTestRun(). + */ virtual void runTest( Test *test ); + /*! \brief Protects a call to the specified functor. + * + * See Protector to understand how protector works. A default protector is + * always present. It captures CppUnit::Exception, std::exception and + * any other exceptions, retrieving as much as possible information about + * the exception as possible. + * + * Additional Protector can be added to the chain to support other exception + * types using pushProtector() and popProtector(). + * + * \param functor Functor to call (typically a call to setUp(), runTest() or + * tearDown(). + * \param test Test the functor is associated to (used for failure reporting). + * \param shortDescription Short description override for the failure message. + */ virtual bool protect( const Functor &functor, Test *test, const std::string &shortDescription = std::string("") ); + /// Adds the specified protector to the protector chain. virtual void pushProtector( Protector *protector ); + /// Removes the last protector from the protector chain. virtual void popProtector(); protected: + /*! \brief Called to add a failure to the list of failures. + */ void addFailure( const TestFailure &failure ); virtual void startTestRun( Test *test ); diff --git a/include/cppunit/TestRunner.h b/include/cppunit/TestRunner.h index 50390f0..930370a 100644 --- a/include/cppunit/TestRunner.h +++ b/include/cppunit/TestRunner.h @@ -72,19 +72,19 @@ class TestResult; class CPPUNIT_API TestRunner { public: - /*! Constructs a TestRunner object. + /*! \brief Constructs a TestRunner object. */ TestRunner( ); /// Destructor. virtual ~TestRunner(); - /*! Adds the specified test. + /*! \brief Adds the specified test. * \param test Test to add. The TestRunner takes ownership of the test. */ virtual void addTest( Test *test ); - /*! Runs a test using the specified controller. + /*! \brief Runs a test using the specified controller. * \param controller Event manager and controller used for testing * \param testPath Test path string. See Test::resolveTestPath() for detail. * \exception std::invalid_argument if no test matching \a testPath is found. diff --git a/include/cppunit/XmlOutputter.h b/include/cppunit/XmlOutputter.h index fafffa2..76a3864 100644 --- a/include/cppunit/XmlOutputter.h +++ b/include/cppunit/XmlOutputter.h @@ -39,7 +39,7 @@ class XmlOutputterHook; class CPPUNIT_API XmlOutputter : public Outputter { public: - /*! Constructs a XmlOutputter object. + /*! \brief Constructs a XmlOutputter object. * \param result Result of the test run. * \param stream Stream used to output the XML output. * \param encoding Encoding used in the XML file (default is Latin-1). @@ -51,24 +51,24 @@ public: /// Destructor. virtual ~XmlOutputter(); - /*! Adds the specified hook to the outputter. + /*! \brief Adds the specified hook to the outputter. * \param hook Hook to add. Must not be \c NULL. */ virtual void addHook( XmlOutputterHook *hook ); - /*! Removes the specified hook from the outputter. + /*! \brief Removes the specified hook from the outputter. * \param hook Hook to remove. */ virtual void removeHook( XmlOutputterHook *hook ); - /*! Writes the specified result as an XML document to the stream. + /*! \brief Writes the specified result as an XML document to the stream. * * Refer to examples/cppunittest/XmlOutputterTest.cpp for example * of use and XML document structure. */ virtual void write(); - /*! Sets the XSL style sheet used. + /*! \brief Sets the XSL style sheet used. * * \param styleSheet Name of the style sheet used. If empty, then no style sheet * is used (default). @@ -78,7 +78,7 @@ public: typedef CppUnitMap<Test *,TestFailure*> FailedTests; - /*! Sets the root element and adds its children. + /*! \brief Sets the root element and adds its children. * * Set the root element of the XML Document and add its child elements. * @@ -94,7 +94,7 @@ public: virtual void addSuccessfulTests( FailedTests &failedTests, XmlElement *rootNode ); - /*! Adds the statics element to the root node. + /*! \brief Adds the statics element to the root node. * * Creates a new element containing statistics data and adds it to the root element. * Then, for all hooks, call statisticsAdded(). @@ -102,7 +102,7 @@ public: */ virtual void addStatistics( XmlElement *rootNode ); - /*! Adds a failed test to the failed tests node. + /*! \brief Adds a failed test to the failed tests node. * Creates a new element containing datas about the failed test, and adds it to * the failed tests element. * Then, for all hooks, call failTestAdded(). @@ -116,7 +116,7 @@ public: XmlElement *testElement ); - /*! Adds a successful test to the successful tests node. + /*! \brief Adds a successful test to the successful tests node. * Creates a new element containing datas about the successful test, and adds it to * the successful tests element. * Then, for all hooks, call successfulTestAdded(). diff --git a/include/cppunit/plugin/DynamicLibraryManager.h b/include/cppunit/plugin/DynamicLibraryManager.h index afb0b4a..b93ebad 100644 --- a/include/cppunit/plugin/DynamicLibraryManager.h +++ b/include/cppunit/plugin/DynamicLibraryManager.h @@ -36,7 +36,7 @@ public: typedef void *Symbol; typedef void *LibraryHandle; - /*! Loads the specified library. + /*! \brief Loads the specified library. * \param libraryFileName Name of the library to load. * \exception DynamicLibraryManagerException if a failure occurs while loading * the library (fail to found or load the library). @@ -46,7 +46,7 @@ public: /// Releases the loaded library.. ~DynamicLibraryManager(); - /*! Returns a pointer on the specified symbol exported by the library. + /*! \brief Returns a pointer on the specified symbol exported by the library. * \param symbol Name of the symbol exported by the library. * \return Pointer on the symbol. Should be casted to the actual type. Never \c NULL. * \exception DynamicLibraryManagerException if the symbol is not found. diff --git a/include/cppunit/plugin/PlugInManager.h b/include/cppunit/plugin/PlugInManager.h index 6baaa2b..a2b8e15 100644 --- a/include/cppunit/plugin/PlugInManager.h +++ b/include/cppunit/plugin/PlugInManager.h @@ -33,7 +33,7 @@ public: /// Destructor. virtual ~PlugInManager(); - /*! Loads the specified plug-in. + /*! \brief Loads the specified plug-in. * * After being loaded, the CppUnitTestPlugIn::initialize() is called. * @@ -46,28 +46,28 @@ public: void load( const std::string &libraryFileName, const PlugInParameters ¶meters = PlugInParameters() ); - /*! Unloads the specified plug-in. + /*! \brief Unloads the specified plug-in. * \param libraryFileName Name of the file that contains the TestPlugIn passed * to a previous call to load(). */ void unload( const std::string &libraryFileName ); - /*! Gives a chance to each loaded plug-in to register TestListener. + /*! \brief Gives a chance to each loaded plug-in to register TestListener. * * For each plug-in, call CppUnitTestPlugIn::addListener(). */ void addListener( TestResult *eventManager ); - /*! Gives a chance to each loaded plug-in to unregister TestListener. + /*! \brief Gives a chance to each loaded plug-in to unregister TestListener. * For each plug-in, call CppUnitTestPlugIn::removeListener(). */ void removeListener( TestResult *eventManager ); - /*! Provides a way for the plug-in to register some XmlOutputterHook. + /*! \brief Provides a way for the plug-in to register some XmlOutputterHook. */ void addXmlOutputterHooks( XmlOutputter *outputter ); - /*! Called when the XmlOutputter is destroyed. + /*! \brief Called when the XmlOutputter is destroyed. * * Can be used to free some resources allocated by addXmlOutputterHooks(). */ diff --git a/include/cppunit/plugin/PlugInParameters.h b/include/cppunit/plugin/PlugInParameters.h index 9a6f075..c67d0f1 100644 --- a/include/cppunit/plugin/PlugInParameters.h +++ b/include/cppunit/plugin/PlugInParameters.h @@ -10,14 +10,17 @@ CPPUNIT_NS_BEGIN - +/*! \brief Test plug-ins parameters. + */ class CPPUNIT_API PlugInParameters { public: + /// Constructs plug-in parameters from the specified command-line. PlugInParameters( const std::string &commandLine = "" ); virtual ~PlugInParameters(); + /// Returns the command line that was passed on construction. std::string getCommandLine() const; private: diff --git a/include/cppunit/plugin/TestPlugIn.h b/include/cppunit/plugin/TestPlugIn.h index 2f3fdde..b2baf5b 100644 --- a/include/cppunit/plugin/TestPlugIn.h +++ b/include/cppunit/plugin/TestPlugIn.h @@ -42,7 +42,7 @@ CPPUNIT_NS_END */ struct CppUnitTestPlugIn { - /*! Called just after loading the dynamic library. + /*! \brief Called just after loading the dynamic library. * * Override this method to add additional suite to the registry, though this * is preferably done using the macros (CPPUNIT_TEST_SUITE_REGISTRATION...). @@ -58,7 +58,7 @@ struct CppUnitTestPlugIn virtual void initialize( CPPUNIT_NS::TestFactoryRegistry *registry, const CPPUNIT_NS::PlugInParameters ¶meters ) =0; - /*! Gives a chance to the plug-in to register TestListener. + /*! \brief Gives a chance to the plug-in to register TestListener. * * Override this method to add a TestListener for the test run. This is useful * if you are writing a custom TestListener, but also if you need to @@ -67,23 +67,23 @@ struct CppUnitTestPlugIn */ virtual void addListener( CPPUNIT_NS::TestResult *eventManager ) =0; - /*! Gives a chance to the plug-in to remove its registered TestListener. + /*! \brief Gives a chance to the plug-in to remove its registered TestListener. * * Override this method to remove a TestListener that has been added. */ virtual void removeListener( CPPUNIT_NS::TestResult *eventManager ) =0; - /*! Provides a way for the plug-in to register some XmlOutputterHook. + /*! \brief Provides a way for the plug-in to register some XmlOutputterHook. */ virtual void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter ) =0; - /*! Called when the XmlOutputter is destroyed. + /*! \brief Called when the XmlOutputter is destroyed. * * Can be used to free some resources allocated by addXmlOutputterHooks(). */ virtual void removeXmlOutputterHooks() = 0; - /*! Called just before unloading the dynamic library. + /*! \brief Called just before unloading the dynamic library. * * Override this method to unregister test factory added in initialize(). * This is necessary to keep the TestFactoryRegistry 'clean'. When @@ -96,7 +96,7 @@ struct CppUnitTestPlugIn -/*! Name of the function exported by a test plug-in. +/*! \brief Name of the function exported by a test plug-in. * \ingroup WritingTestPlugIn * * The signature of the exported function is: @@ -106,13 +106,13 @@ struct CppUnitTestPlugIn */ #define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn -/*! Type of the function exported by a plug-in. +/*! \brief Type of the function exported by a plug-in. * \ingroup WritingTestPlugIn */ typedef CppUnitTestPlugIn *(*TestPlugInSignature)(); -/*! Implements the function exported by the test plug-in +/*! \brief Implements the function exported by the test plug-in * \ingroup WritingTestPlugIn */ #define CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( TestPlugInInterfaceType ) \ @@ -172,7 +172,7 @@ typedef CppUnitTestPlugIn *(*TestPlugInSignature)(); -/*! Implements and exports the test plug-in interface. +/*! \brief Implements and exports the test plug-in interface. * \ingroup WritingTestPlugIn * * This macro exports the test plug-in function using the subclass, |
