CppUnit project page | FAQ | CppUnit home page |
#include <TextTestRunner.h>
Public Member Functions | |
TextTestRunner (Outputter *outputter=NULL) | |
virtual | ~TextTestRunner () |
bool | run (std::string testPath="", bool doWait=false, bool doPrintResult=true, bool doPrintProgress=true) |
void | setOutputter (Outputter *outputter) |
TestResultCollector & | result () const |
TestResult & | eventManager () const |
Protected Member Functions | |
virtual void | wait (bool doWait) |
virtual void | printResult (bool doPrintResult) |
Protected Attributes | |
TestResultCollector * | m_result |
TestResult * | m_eventManager |
Outputter * | m_outputter |
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. The trace and summary print are optional.
Here is an example of use:
CppUnit::TextTestRunner runner; runner.addTest( ExampleTestCase::suite() ); runner.run( "", true ); // Run all tests and wait
The trace is printed using a TextTestProgressListener. The summary is printed using a TextOutputter.
You can specify an alternate Outputter at construction or later with setOutputter().
After construction, you can register additional TestListener to eventManager(), for a custom progress trace, for example.
CppUnit::TextTestRunner runner; runner.addTest( ExampleTestCase::suite() ); runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( &runner.result(), std::cerr ) ); MyCustomProgressTestListener progress; runner.eventManager().addListener( &progress ); runner.run( "", true ); // Run all tests and wait
|
Constructs a new text runner.
|
|
|
|
Returns the event manager. The instance of TestResult results returned is the one that is used to run the test. Use this to register additional TestListener before running the tests. |
|
|
|
Returns the result of the test run. Use this after calling run() to access the result of the test run. |
|
Runs the named test case.
|
|
Specifies an alternate outputter.
Notes that the outputter will be use after the test run only if printResult was
|
|
|
|
|
|
|
|
|
hosts this site. |
Send comments to: CppUnit Developers |