1#ifndef CPPUNIT_TESTLISTENER_H // -*- C++ -*- 2#define CPPUNIT_TESTLISTENER_H 3 4#include <cppunit/Portability.h> 5 6 7namespace CppUnit { 8 9class Exception; 10class Test; 11class TestFailure; 12 13 14/*! \brief Listener for test progress and result. 15 * \ingroup TrackingTestExecution 16 * 17 * Implementing the Observer pattern a TestListener may be registered 18 * to a TestResult to obtain information on the testing progress. Use 19 * specialized sub classes of TestListener for text output 20 * (TextTestProgressListener). Do not use the Listener for the test 21 * result output, use a subclass of Outputter instead. 22 * 23 * The test framework distinguishes between failures and errors. 24 * A failure is anticipated and checked for with assertions. Errors are 25 * unanticipated problems signified by exceptions that are not generated 26 * by the framework. 27 * 28 * \see TestResult 29 */ 30class CPPUNIT_API TestListener 31{ 32public: 33 virtual ~TestListener() {} 34 35 /// Called when just before a TestCase is run. 36 virtual void startTest( Test *test ) {} 37 38 /*! Called when a failure occurs while running a test. 39 * \see TestFailure. 40 * \warning \a failure is a temporary object that is destroyed after the 41 * method call. Use TestFailure::clone() to create a duplicate. 42 */ 43 virtual void addFailure( const TestFailure &failure ) {} 44 45 /// Called just after a TestCase was run (even if a failure occured). 46 virtual void endTest( Test *test ) {} 47}; 48 49 50} // namespace CppUnit 51 52#endif // CPPUNIT_TESTLISTENER_H 53 54 55