From fed3ef0b01704ee7fd9f41e8cbb706da38c004fe Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Sat, 19 May 2001 10:29:11 +0000 Subject: * Merged Steve M. Robbins patch to replace assertImplementation with assert in hierarchy example. * Added a TextTestRunner to runner tests. It is based on Michael Feather's version, but have been rewriten. * Removed traces that printed the test name in TextTestResult while running. * Added the test name to error and failure report in TextTestResult. * Updated hierarchy example to use TextTestRunner. --- include/cppunit/TextTestRunner.h | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 include/cppunit/TextTestRunner.h (limited to 'include/cppunit') diff --git a/include/cppunit/TextTestRunner.h b/include/cppunit/TextTestRunner.h new file mode 100644 index 0000000..1310def --- /dev/null +++ b/include/cppunit/TextTestRunner.h @@ -0,0 +1,52 @@ +#ifndef CPPUNIT_TEXTTESTRUNNER_H +#define CPPUNIT_TEXTTESTRUNNER_H + +#include +#include + +namespace CppUnit { + +class Test; +class TestSuite; + +/** + * A text mode test runner. + * + * The test runner manage the life cycle of the added tests. + * + * The test runner can run only one of the added tests or all the tests. + * + * TestRunner prints out a trace as the tests are executed followed by a + * summary at the end. + * + * Here is an example of use: + * + * \code + * TextTestRunner runner; + * runner.addTest( ExampleTestCase::suite() ); + * runner.run( "", true ); // Run all tests and wait + * \endcode + */ +class TextTestRunner +{ +public: + TextTestRunner(); + virtual ~TextTestRunner(); + + void run( std::string testName ="", + bool wait = false ); + + void addTest( Test *test ); + +protected: + void runTest( Test *test ); + void runTestByName( std::string testName ); + void wait( bool doWait ); + + Test *findTestByName( std::string name ) const; + TestSuite *m_suite; +}; + +} // namespace CppUnit + +#endif // CPPUNIT_TEXTTESTRUNNER_H \ No newline at end of file -- cgit v1.2.1