TestCaller< Fixture > Class Template Reference
[Writing test fixture]
Generate a test case from a fixture method.
More...
#include <TestCaller.h>
Inheritance diagram for TestCaller< Fixture >:
_map" border="0" alt="">
List of all members.
Public Member Functions
FIXME: this should probably be pure virtual.
Set up context before running a test.
Clean up after the test run.
Private Types
Private Member Functions
Private Attributes
Detailed Description
template<class Fixture>
class TestCaller< Fixture >
Generate a test case from a fixture method.
A test caller provides access to a test case method on a test fixture class. Test callers are useful when you want to run an individual test or add it to a suite. Test Callers invoke only one Test (i.e. test method) on one Fixture of a TestFixture.
Here is an example:
class MathTest : public CppUnit::TestFixture {
...
public:
void setUp();
void tearDown();
void testAdd();
void testSubtract();
};
CppUnit::Test *MathTest::suite() {
CppUnit::TestSuite *suite = new CppUnit::TestSuite;
suite->addTest( new CppUnit::TestCaller<MathTest>( "testAdd", testAdd ) );
return suite;
}
You can use a TestCaller to bind any test method on a TestFixture class, as long as it accepts void and returns void.
- See also:
- TestCase
Member Typedef Documentation
Constructor & Destructor Documentation
template<class Fixture>
)
[inline]
Constructor for TestCaller. This constructor builds a new Fixture instance owned by the TestCaller.
- Parameters:
-
name name of this TestCaller
test the method this TestCaller calls in
runTest()
template<class Fixture>
Fixture &
fixture
)
[inline]
Constructor for TestCaller. This constructor does not create a new Fixture instance but accepts an existing one as parameter. The TestCaller will not own the Fixture object.
- Parameters:
-
name name of this TestCaller
test the method this TestCaller calls in
runTest()
fixture the Fixture to invoke the test method on.
template<class Fixture>
Fixture *
fixture
)
[inline]
Constructor for TestCaller. This constructor does not create a new Fixture instance but accepts an existing one as parameter. The TestCaller will own the Fixture object and delete it in its destructor.
- Parameters:
-
name name of this TestCaller
test the method this TestCaller calls in
runTest()
fixture the Fixture to invoke the test method on.
Member Function Documentation
template<class Fixture>
void
TestCaller< Fixture >::runTest
(
)
[inline, virtual]
FIXME: this should probably be pure virtual.
Reimplemented from TestCase.
template<class Fixture>
void
TestCaller< Fixture >::setUp
(
)
[inline, virtual]
Set up context before running a test.
Reimplemented from TestFixture.
template<class Fixture>
void
TestCaller< Fixture >::tearDown
(
)
[inline, virtual]
Clean up after the test run.
Reimplemented from TestFixture.
template<class Fixture>
std::string
TestCaller< Fixture >::toString
(
)
const
[inline]
Member Data Documentation
The documentation for this class was generated from the following file: