Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages
A text mode test runner.
More...
#include <TestRunner.h>
List of all members.
Detailed Description
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. The trace and summary print are optional.
Here is an example of use:
CppUnit::TextUi::TestRunner runner;
runner.addTest( ExampleTestCase::suite() );
runner.run( "", true );
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::TextUi::TestRunner runner;
runner.addTest( ExampleTestCase::suite() );
runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
&runner.result(),
std::cerr ) );
MyCustomProgressTestListener progress;
runner.eventManager().addListener( &progress );
runner.run( "", true );
-
See also:
-
CompilerOutputter, XmlOutputter, TextOutputter.
Constructor & Destructor Documentation
CppUnit::TextUi::TestRunner::TestRunner |
( |
Outputter * |
outputter = NULL |
) |
|
|
|
Constructs a new text runner. -
Parameters:
-
outputter |
used to print text result. Owned by the runner. |
|
CppUnit::TextUi::TestRunner::~TestRunner |
( |
|
) |
[virtual] |
|
Member Function Documentation
void CppUnit::TextUi::TestRunner::addTest |
( |
Test * |
test |
) |
|
|
|
Adds the specified test. -
Parameters:
-
|
TestResult & CppUnit::TextUi::TestRunner::eventManager |
( |
|
) |
const |
|
|
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. |
Test * CppUnit::TextUi::TestRunner::findTestByName |
( |
std::string |
name |
) |
const [protected, virtual] |
|
void CppUnit::TextUi::TestRunner::printResult |
( |
bool |
doPrintResult |
) |
[protected, virtual] |
|
|
Returns the result of the test run. Use this after calling run() to access the result of the test run. |
bool CppUnit::TextUi::TestRunner::run |
( |
std::string |
testName = "", |
|
|
bool |
doWait = false, |
|
|
bool |
doPrintResult = true, |
|
|
bool |
doPrintProgress = true |
|
) |
|
|
|
Runs the named test case. -
Parameters:
-
testName |
Name of the test case to run. If an empty is given, then all added test are run. The name must be the name of of an added test. |
doWait |
if true then the user must press the RETURN key before the run() method exit. |
doPrintResult |
if true (default) then the test result are printed on the standard output. |
doPrintProgress |
if true (default) then TextTestProgressListener is used to show the progress. |
-
Returns:
-
true is the test was successful, false if the test failed or was not found. |
bool CppUnit::TextUi::TestRunner::runTest |
( |
Test * |
test, |
|
|
bool |
doPrintProgress |
|
) |
[protected, virtual] |
|
bool CppUnit::TextUi::TestRunner::runTestByName |
( |
std::string |
testName, |
|
|
bool |
printProgress |
|
) |
[protected, virtual] |
|
void CppUnit::TextUi::TestRunner::setOutputter |
( |
Outputter * |
outputter |
) |
|
|
void CppUnit::TextUi::TestRunner::wait |
( |
bool |
doWait |
) |
[protected, virtual] |
|
Member Data Documentation
TestResult* CppUnit::TextUi::TestRunner::m_eventManager [protected]
|
|
Outputter* CppUnit::TextUi::TestRunner::m_outputter [protected]
|
|
TestSuite* CppUnit::TextUi::TestRunner::m_suite [protected]
|
|
The documentation for this class was generated from the following files: