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 .
class TestDecorator : public Test
Constructs a TestDecorator to decorate test .
A destructor. Does not delete the decorated Test .
Returns the value of countTestCases( ) for the decorated Test .
Returns the name of the decorated Test .
Calls run(result) on the decorated Test .
Returns the value of toString( ) for the decorated Test .
A copy constructor declared private to prevent its use.
A copy operator declared private to prevent its use.
The Test decorated by this TestDecorator ( protected ).