Name
TestRunner
Description
The class TestRunner
(see Figure C-28) provides the user interface to run tests and
output the results. CppUnit includes three versions of
TestRunner: a text version, a Qt GUI version, and
an MFC GUI version. The text version is summarized here, since it is
the most generic. The usage of the other two versions is similar.
The code sample below demonstrates using
TestRunner to run BookTest and
print the results. A TestSuite containing multiple
Test objects can be run the same way.
TestRunner runner;
runner.addTest( BookTest );
runner.run( );The text TestRunner belongs to the namespace
CppUnit::TextUi. It is declared in the file
ui/text/TestRunner.h and implemented in the file
TestRunner.cpp.
![]() |
Declaration
class TestRunner
Constructors/Destructors
-
TestRunner(Outputter *outputter = NULL) Constructs a
TestRunner. If noOutputteris provided, aTextOutputterthat prints tostdoutis created.-
virtual ~TestRunner( ) A destructor.
Public Methods
-
void addTest(Test *test) Adds a
Testto thisTestRunner. MultipleTestobjects may be added.-
TestResult &eventManager( ) const Returns the
TestResultfor thisTestRunner. AdditionalTestListenerobjects can be added to theTestResultto obtain test progress and results notifications.-
TestResultCollector &result( ) const Returns the
TestResultCollectorcontaining the results of theTest ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
