Blame include/cppunit/Test.h

Packit 8c9aa0
#ifndef CPPUNIT_TEST_H
Packit 8c9aa0
#define CPPUNIT_TEST_H
Packit 8c9aa0
Packit 8c9aa0
#include <cppunit/Portability.h>
Packit 8c9aa0
#include <string>
Packit 8c9aa0
Packit 8c9aa0
CPPUNIT_NS_BEGIN
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
class TestResult;
Packit 8c9aa0
class TestPath;
Packit 8c9aa0
Packit 8c9aa0
/*! \brief Base class for all test objects.
Packit 8c9aa0
 * \ingroup BrowsingCollectedTestResult
Packit 8c9aa0
 *
Packit 8c9aa0
 * All test objects should be a subclass of Test.  Some test objects,
Packit 8c9aa0
 * TestCase for example, represent one individual test.  Other test
Packit 8c9aa0
 * objects, such as TestSuite, are comprised of several tests.  
Packit 8c9aa0
 *
Packit 8c9aa0
 * When a Test is run, the result is collected by a TestResult object.
Packit 8c9aa0
 *
Packit 8c9aa0
 * \see TestCase
Packit 8c9aa0
 * \see TestSuite
Packit 8c9aa0
 */
Packit 8c9aa0
class CPPUNIT_API Test
Packit 8c9aa0
{
Packit 8c9aa0
public:
Packit 8c9aa0
  virtual ~Test() {};
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Run the test, collecting results.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual void run( TestResult *result ) =0;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Return the number of test cases invoked by run().
Packit 8c9aa0
   *
Packit 8c9aa0
   * The base unit of testing is the class TestCase.  This
Packit 8c9aa0
   * method returns the number of TestCase objects invoked by
Packit 8c9aa0
   * the run() method.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual int countTestCases () const =0;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Returns the number of direct child of the test.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual int getChildTestCount() const =0;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Returns the child test of the specified index.
Packit 8c9aa0
   *
Packit 8c9aa0
   * This method test if the index is valid, then call doGetChildTestAt() if 
Packit 8c9aa0
   * the index is valid. Otherwise std::out_of_range exception is thrown.
Packit 8c9aa0
   *
Packit 8c9aa0
   * You should override doGetChildTestAt() method.
Packit 8c9aa0
   * 
Packit 8c9aa0
   * \param index Zero based index of the child test to return.
Packit 8c9aa0
   * \return Pointer on the test. Never \c NULL.
Packit 8c9aa0
   * \exception std::out_of_range is \a index is < 0 or >= getChildTestCount().
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual Test *getChildTestAt( int index ) const;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Returns the test name.
Packit 8c9aa0
   * 
Packit 8c9aa0
   * Each test has a name.  This name may be used to find the
Packit 8c9aa0
   * test in a suite or registry of tests.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual std::string getName () const =0;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Finds the test with the specified name and its parents test.
Packit 8c9aa0
   * \param testName Name of the test to find.
Packit 8c9aa0
   * \param testPath If the test is found, then all the tests traversed to access
Packit 8c9aa0
   *                 \a test are added to \a testPath, including \c this and \a test.
Packit 8c9aa0
   * \return \c true if a test with the specified name is found, \c false otherwise.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual bool findTestPath( const std::string &testName,
Packit 8c9aa0
                             TestPath &testPath ) const;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Finds the specified test and its parents test.
Packit 8c9aa0
   * \param test Test to find.
Packit 8c9aa0
   * \param testPath If the test is found, then all the tests traversed to access
Packit 8c9aa0
   *                 \a test are added to \a testPath, including \c this and \a test.
Packit 8c9aa0
   * \return \c true if the specified test is found, \c false otherwise.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual bool findTestPath( const Test *test,
Packit 8c9aa0
                             TestPath &testPath ) const;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Finds the test with the specified name in the hierarchy.
Packit 8c9aa0
   * \param testName Name of the test to find.
Packit 8c9aa0
   * \return Pointer on the first test found that is named \a testName. Never \c NULL.
Packit 8c9aa0
   * \exception std::invalid_argument if no test named \a testName is found.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual Test *findTest( const std::string &testName ) const;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Resolved the specified test path with this test acting as 'root'.
Packit 8c9aa0
   * \param testPath Test path string to resolve.
Packit 8c9aa0
   * \return Resolved TestPath. 
Packit 8c9aa0
   * \exception std::invalid_argument if \a testPath could not be resolved.
Packit 8c9aa0
   * \see TestPath.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual TestPath resolveTestPath( const std::string &testPath ) const;
Packit 8c9aa0
Packit 8c9aa0
protected:
Packit 8c9aa0
  /*! Throws an exception if the specified index is invalid.
Packit 8c9aa0
   * \param index Zero base index of a child test.
Packit 8c9aa0
   * \exception std::out_of_range is \a index is < 0 or >= getChildTestCount().
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual void checkIsValidIndex( int index ) const;
Packit 8c9aa0
Packit 8c9aa0
  /*! \brief Returns the child test of the specified valid index.
Packit 8c9aa0
   * \param index Zero based valid index of the child test to return.
Packit 8c9aa0
   * \return Pointer on the test. Never \c NULL.
Packit 8c9aa0
   */
Packit 8c9aa0
  virtual Test *doGetChildTestAt( int index ) const =0;
Packit 8c9aa0
};
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
CPPUNIT_NS_END
Packit 8c9aa0
Packit 8c9aa0
#endif // CPPUNIT_TEST_H
Packit 8c9aa0