CppUnit project page | FAQ |
Expected exception test case decorator. More...
#include <ExceptionTestCaseDecorator.h>
Public Types | |
typedef ExpectedException | ExpectedExceptionType |
Public Member Functions | |
ExceptionTestCaseDecorator (TestCase *test) | |
Decorates the specified test. | |
void | runTest () |
Checks that the expected exception is thrown by the decorated test. is thrown. | |
Public Member Functions inherited from TestCaseDecorator | |
TestCaseDecorator (TestCase *test) | |
~TestCaseDecorator () | |
std::string | getName () const |
Returns the name of the test case. | |
void | setUp () |
Set up context before running a test. | |
void | tearDown () |
Clean up after the test run. | |
Public Member Functions inherited from TestCase | |
TestCase (const std::string &name) | |
Constructs a test case. | |
TestCase () | |
Constructs a test case for a suite. | |
~TestCase () | |
Destructs a test case. | |
virtual void | run (TestResult *result) |
Run the test and catch any exceptions that are triggered by it. | |
Public Member Functions inherited from TestLeaf | |
int | countTestCases () const |
int | getChildTestCount () const |
Test * | doGetChildTestAt (int index) const |
Public Member Functions inherited from Test | |
virtual | ~Test () |
virtual Test * | getChildTestAt (int index) const |
Returns the child test of the specified index. | |
virtual bool | findTestPath (const std::string &testName, TestPath &testPath) const |
Finds the test with the specified name and its parents test. | |
virtual bool | findTestPath (const Test *test, TestPath &testPath) const |
Finds the specified test and its parents test. | |
virtual Test * | findTest (const std::string &testName) const |
Finds the test with the specified name in the hierarchy. | |
virtual TestPath | resolveTestPath (const std::string &testPath) const |
Resolved the specified test path with this test acting as 'root'. | |
Public Member Functions inherited from TestFixture | |
virtual | ~TestFixture () |
Private Member Functions | |
virtual void | checkException (ExpectedExceptionType &) |
Called when the exception is caught. |
Additional Inherited Members | |
Protected Attributes inherited from TestCaseDecorator | |
TestCase * | m_test |
Expected exception test case decorator.
A decorator used to assert that a specific test case should throw an exception of a given type.
You should use this class only if you need to check the exception object state (that a specific cause is set for example). If you don't need to do that, you might consider using CPPUNIT_TEST_EXCEPTION() instead.
Intended use is to subclass and override checkException(). Example:
typedef ExpectedException ExceptionTestCaseDecorator< ExpectedException >::ExpectedExceptionType |
|
inline |
Decorates the specified test.
test | TestCase to decorate. Assumes ownership of the test. |
|
inlineprivatevirtual |
Called when the exception is caught.
Should be overriden to check the exception.
|
inlinevirtual |
Checks that the expected exception is thrown by the decorated test. is thrown.
Calls the decorated test runTest() and checks that an exception of type ExpectedException is thrown. Call checkException() passing the exception that was caught so that some assertions can be made if needed.
Reimplemented from TestCaseDecorator.
Send comments to: CppUnit Developers |