The template class TestCaller (see Figure C-17) is used to create and run a TestCase containing a TestMethod , usually in the context of a TestFixture . This is useful when a TestFixture has multiple test methods but only one of them should be run, or when test methods are being run by name . A TestMethod must take no arguments and return void to be invoked using TestCaller .
When TestCaller is specialized and instantiated , the type Fixture should be TestFixture or a subclass of it. The type ExpectedException defaults to NoExceptionExpected , meaning that an Exception is not expected when the TestMethod is run, and the test fails if one is thrown. An Exception type can be provided when TestCaller is specialized, so that it is expected when the TestCase is run. In this case, the test fails if the ExpectedException is not thrown.
TestCaller belongs to the namespace CppUnit . It is declared and implemented in TestCaller.h .
template<typename Fixture, typename ExpectedException = NoExceptionExpected> class TestCaller : public TestCase
A constructor used when a TestFixture is not provided. In this case, the TestMethod is run in a new, default TestFixture owned by the TestCaller .
A constructor taking a TestMethod and a reference to a TestFixture . The TestCaller does not own the TestFixture in this case.
A constructor taking a TestMethod and a pointer to a TestFixture . When a TestCaller is constructed this way, it owns the TestFixture .
A destructor. If the TestCaller owns the TestFixture , it deletes it.
A Protected method that runs the TestMethod .
A Protected method that sets up the Fixture by calling its setUp( ) method.
A Protected method that tears down the Fixture by calling its tearDown( ) method.
A Protected method returning a string representation of this TestCaller .
A copy constructor declared private to prevent its use.
A copy operator declared private to prevent its use.
A pointer to Fixture ( private ).
If TRUE , TestCaller owns Fixture and deletes it in its destructor ( private ).
The TestMethod that this TestCaller will run ( private ).