Blame include/cppunit/Test.h

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