1//
2// TestFailure.h
3//
4
5
6#ifndef Poco_CppUnit_TestFailure_INCLUDED
7#define Poco_CppUnit_TestFailure_INCLUDED
8
9
10#include "Poco/CppUnit/CppUnit.h"
11#include "Poco/CppUnit/CppUnitException.h"
12#include "Poco/CppUnit/Guards.h"
13
14
15namespace CppUnit {
16
17
18class Test;
19
20
21/*
22 * A TestFailure collects a failed test together with
23 * the caught exception.
24 *
25 * TestFailure assumes lifetime control for any exception
26 * passed to it. The lifetime of tests is handled by
27 * their TestSuite (if they have been added to one) or
28 * whomever creates them.
29 *
30 * see TestResult
31 * see TestSuite
32 *
33 */
34class CppUnit_API TestFailure
35{
36 REFERENCEOBJECT (TestFailure)
37
38public:
39 TestFailure(Test* failedTest, CppUnitException* thrownException);
40 ~TestFailure();
41
42 Test* failedTest();
43 CppUnitException* thrownException();
44 std::string toString();
45
46protected:
47 Test* _failedTest;
48 CppUnitException *_thrownException;
49};
50
51
52// Constructs a TestFailure with the given test and exception.
53inline TestFailure::TestFailure(Test* failedTest, CppUnitException* thrownException): _failedTest(failedTest), _thrownException(thrownException)
54{
55}
56
57
58// Deletes the owned exception.
59inline TestFailure::~TestFailure()
60{
61 delete _thrownException;
62}
63
64
65// Gets the failed test.
66inline Test* TestFailure::failedTest()
67{
68 return _failedTest;
69}
70
71
72// Gets the thrown exception.
73inline CppUnitException* TestFailure::thrownException()
74{
75 return _thrownException;
76}
77
78
79} // namespace CppUnit
80
81
82#endif // Poco_CppUnit_TestFailure_INCLUDED
83
84
85