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 noOutputter
is provided, aTextOutputter
that prints tostdout
is created.-
virtual ~TestRunner( )
A destructor.
Public Methods
-
void addTest(Test *test)
Adds a
Test
to thisTestRunner
. MultipleTest
objects may be added.-
TestResult &eventManager( ) const
Returns the
TestResult
for thisTestRunner
. AdditionalTestListener
objects can be added to theTestResult
to obtain test progress and results notifications.-
TestResultCollector &result( ) const
Returns the
TestResultCollector
containing the results of theTest ...
Get Unit Test Frameworks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.