Name
TestCaller
Description
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.
![]() |
Declaration
template<typename Fixture, typename ExpectedException = NoExceptionExpected> class TestCaller : public TestCase
Constructors/Destructors
-
TestCaller(string name, TestMethod test) A constructor used when a
TestFixtureis not provided. In this case, theTestMethodis run in a new, defaultTestFixtureowned by theTestCaller.-
TestCaller(string name, TestMethod test, Fixture& fixture) A constructor taking ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
