CppUnit - The Unit Testing Library

CppUnit project page | FAQ

TestResult.h
Go to the documentation of this file.
1 #ifndef CPPUNIT_TESTRESULT_H
2 #define CPPUNIT_TESTRESULT_H
3
4 #include <cppunit/Portability.h>
5
6 #if CPPUNIT_NEED_DLL_DECL
7 #pragma warning( push )
8 #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
9 #endif
10
11 #include <cppunit/SynchronizedObject.h>
12 #include <cppunit/portability/CppUnitDeque.h>
13 #include <string>
14
15 CPPUNIT_NS_BEGIN
16
17
18 class Exception;
19 class Functor;
20 class Protector;
21 class ProtectorChain;
22 class Test;
23 class TestFailure;
24 class TestListener;
25
26
27 #if CPPUNIT_NEED_DLL_DECL
28 // template class CPPUNIT_API std::deque<TestListener *>;
29 #endif
30
51 class CPPUNIT_API TestResult : protected SynchronizedObject
52 {
53 public:
55 TestResult( SynchronizationObject *syncObject = 0 );
56
58 virtual ~TestResult();
59
60 virtual void addListener( TestListener *listener );
61
62 virtual void removeListener( TestListener *listener );
63
65 virtual void reset();
66
68 virtual void stop();
69
71 virtual bool shouldStop() const;
72
74 virtual void startTest( Test *test );
75
80 virtual void addError( Test *test, Exception *e );
81
85 virtual void addFailure( Test *test, Exception *e );
86
88 virtual void endTest( Test *test );
89
91 virtual void startSuite( Test *test );
92
94 virtual void endSuite( Test *test );
95
100 virtual void runTest( Test *test );
101
117 virtual bool protect( const Functor &functor,
118 Test *test,
119 const std::string &shortDescription = std::string("") );
120
122 virtual void pushProtector( Protector *protector );
123
125 virtual void popProtector();
126
127 protected:
130 void addFailure( const TestFailure &failure );
131
132 virtual void startTestRun( Test *test );
133 virtual void endTestRun( Test *test );
134
135 protected:
136 typedef CppUnitDeque<TestListener *> TestListeners;
137 TestListeners m_listeners;
138 ProtectorChain *m_protectorChain;
139 bool m_stop;
140
141 private:
142 TestResult( const TestResult &other );
143 TestResult &operator =( const TestResult &other );
144 };
145
146
147 CPPUNIT_NS_END
148
149
150 #if CPPUNIT_NEED_DLL_DECL
151 #pragma warning( pop )
152 #endif
153
154 #endif // CPPUNIT_TESTRESULT_H
155
156
Exception
Exceptions thrown by failed assertions.Exception is an exception that serves descriptive strings thro...
Definition: Exception.h:19
Protector
Protects one or more test case run.
Definition: Protector.h:47
TestResult
Manages TestListener.A single instance of this class is used when running the test. It is usually created by the test runner (TestRunner).
Definition: TestResult.h:51
Portability.h
TestResult::m_listeners
TestListeners m_listeners
Definition: TestResult.h:137
TestResult::m_protectorChain
ProtectorChain * m_protectorChain
Definition: TestResult.h:138
Test
Base class for all test objects.All test objects should be a subclass of Test. Some test objects...
Definition: Test.h:25
Functor
Definition: Protector.h:14
TestResult::m_stop
bool m_stop
Definition: TestResult.h:139
SynchronizedObject::SynchronizationObject
Abstract synchronization object (mutex)
Definition: SynchronizedObject.h:27
TestFailure
Record of a failed Test execution.A TestFailure collects a failed test together with the caught excep...
Definition: TestFailure.h:24
ProtectorChain
Protector chain (Implementation). Implementation detail.
Definition: ProtectorChain.h:19
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:120
SynchronizedObject.h
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:119
TestListener
Listener for test progress and result.Implementing the Observer pattern a TestListener may be registe...
Definition: TestListener.h:94
TestResult::TestListeners
CppUnitDeque< TestListener * > TestListeners
Definition: TestResult.h:136
SynchronizedObject::operator=
void operator=(const SynchronizedObject &copy)
Prevents the use of the copy operator.
CppUnitDeque.h
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27
SynchronizedObject
Base class for synchronized object.
Definition: SynchronizedObject.h:22

| Send comments to: CppUnit Developers