Name
TestDecorator
Description
The class
TestDecorator
(see Figure C-19) allows
the functionality of a Test
to be extended without
subclassing it. TestDecorator
implements the
Test
interface and thus can be run like any other
Test
. When constructed, it takes a reference to
another Test
that it
“decorates,” or wraps. A
TestDecorator
modifies the decorated
Test
by performing other operations before or
after running it.
The classes RepeatedTest
and
TestSetUp
are subclasses of
TestDecorator
and provide practical examples of
its usage. The base implementation of
TestDecorator
simply is a wrapper for a
Test
and does not change its operation.
TestDecorator
belongs to the namespace
CppUnit
. It is declared and implemented in
extensions/TestDecorator.h.
Declaration
class TestDecorator : public Test
Constructors/Destructors
-
TestDecorator(Test *test)
Constructs a
TestDecorator
to decoratetest
.-
~TestDecorator( )
A destructor. Does not delete the decorated
Test
.
Public Methods
-
int countTestCases( ) const
Returns the value of
countTestCases( )
for the decoratedTest
.-
string getName( ) const
Returns the name of the decorated
Test
.-
void run(TestResult *result)
Calls
run(result)
on the decoratedTest
.-
string toString( ) const
Returns the value of
toString( )
for the decoratedTest
.
Protected/Private Methods
-
TestDecorator(const TestDecorator &other)
A copy constructor declared ...
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.