1 #ifndef CPPUNIT_TEST_H 2 #define CPPUNIT_TEST_H 3 4 #include <cppunit/Portability.h> 5 #include <string> 6 7 namespace CppUnit { 8 9 class TestResult; 10 11 /*! \brief Base class for all test objects. 12 * \ingroup BrowsingCollectedTestResult 13 * 14 * All test objects should be a subclass of Test. Some test objects, 15 * TestCase for example, represent one individual test. Other test 16 * objects, such as TestSuite, are comprised of several tests. 17 * 18 * When a Test is run, the result is collected by a TestResult object. 19 * 20 * \see TestCase 21 * \see TestSuite 22 */ 23 class CPPUNIT_API Test 24 { 25 public: ~Test()26 virtual ~Test () {}; 27 28 /*! \brief Run the test, collecting results. 29 */ 30 virtual void run (TestResult *result) = 0; 31 32 /*! \brief Return the number of test cases invoked by run(). 33 * 34 * The base unit of testing is the class TestCase. This 35 * method returns the number of TestCase objects invoked by 36 * the run() method. 37 */ 38 virtual int countTestCases () const = 0; 39 40 /*! \brief Returns the test name. 41 * 42 * Each test has a name. This name may be used to find the 43 * test in a suite or registry of tests. 44 */ 45 virtual std::string getName () const = 0; 46 47 /*! \brief Description of the test, for diagnostic output. 48 * 49 * The test description will typically include the test name, 50 * but may have additional description. For example, a test 51 * suite named <tt>complex_add</tt> may be described as 52 * <tt>suite complex_add</tt>. 53 */ 54 virtual std::string toString () const = 0; 55 56 57 }; 58 59 60 } // namespace CppUnit 61 62 #endif // CPPUNIT_TEST_H 63 64