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 <deque>
13#include <string>
14
15 CPPUNIT_NS_BEGIN
16
17
18class Exception;
19class Functor;
20class Protector;
21class ProtectorChain;
22class Test;
23class TestFailure;
24class TestListener;
25
26
47 class CPPUNIT_API TestResult : protected SynchronizedObject
48{
49public:
51 TestResult( SynchronizationObject *syncObject = 0 );
52
54 virtual ~TestResult();
55
56 virtual void addListener( TestListener *listener );
57
58 virtual void removeListener( TestListener *listener );
59
61 virtual void reset();
62
64 virtual void stop();
65
67 virtual bool shouldStop() const;
68
70 virtual void startTest( Test *test );
71
76 virtual void addError( Test *test, Exception *e );
77
81 virtual void addFailure( Test *test, Exception *e );
82
84 virtual void endTest( Test *test );
85
87 virtual void startSuite( Test *test );
88
90 virtual void endSuite( Test *test );
91
96 virtual void runTest( Test *test );
97
113 virtual bool protect( const Functor &functor,
114 Test *test,
115 const std::string &shortDescription = std::string("") );
116
118 virtual void pushProtector( Protector *protector );
119
121 virtual void popProtector();
122
123protected:
126 void addFailure( const TestFailure &failure );
127
128 virtual void startTestRun( Test *test );
129 virtual void endTestRun( Test *test );
130
131protected:
132 typedef std::deque<TestListener *> TestListeners;
133 TestListeners m_listeners;
134 ProtectorChain *m_protectorChain;
135 bool m_stop;
136
137private:
138 TestResult( const TestResult &other );
139 TestResult &operator =( const TestResult &other );
140};
141
142
143 CPPUNIT_NS_END
144
145
146#if CPPUNIT_NEED_DLL_DECL
147#pragma warning( pop )
148#endif
149
150#endif // CPPUNIT_TESTRESULT_H
151
152
CPPUNIT_API
#define CPPUNIT_API
Definition CppUnitApi.h:27
Portability.h
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition Portability.h:106
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition Portability.h:105
SynchronizedObject.h
Exception
Exceptions thrown by failed assertions.
Definition Exception.h:20
Functor
Definition Protector.h:15
ProtectorChain
Protector chain (Implementation). Implementation detail.
Definition ProtectorChain.h:20
Protector
Protects one or more test case run.
Definition Protector.h:48
SynchronizedObject::SynchronizationObject
Abstract synchronization object (mutex).
Definition SynchronizedObject.h:28
SynchronizedObject::SynchronizedObject
SynchronizedObject(SynchronizationObject *syncObject=0)
Definition SynchronizedObject.cpp:7
SynchronizedObject::operator=
void operator=(const SynchronizedObject &copy)
Prevents the use of the copy operator.
TestFailure
Record of a failed Test execution.
Definition TestFailure.h:25
Test
Base class for all test objects.
Definition Test.h:26
TestListener
Listener for test progress and result.
Definition TestListener.h:95
TestResult::pushProtector
virtual void pushProtector(Protector *protector)
Adds the specified protector to the protector chain.
Definition TestResult.cpp:187
TestResult::endTest
virtual void endTest(Test *test)
Informs TestListener that a test was completed.
Definition TestResult.cpp:81
TestResult::addFailure
virtual void addFailure(Test *test, Exception *e)
Adds a failure to the list of failures. The passed in exception caused the failure.
Definition TestResult.cpp:51
TestResult::protect
virtual bool protect(const Functor &functor, Test *test, const std::string &shortDescription=std::string(""))
Protects a call to the specified functor.
Definition TestResult.cpp:177
TestResult::popProtector
virtual void popProtector()
Removes the last protector from the protector chain.
Definition TestResult.cpp:194
TestResult::addListener
virtual void addListener(TestListener *listener)
Definition TestResult.cpp:130
TestResult::startTestRun
virtual void startTestRun(Test *test)
Definition TestResult.cpp:155
TestResult::stop
virtual void stop()
Stop testing.
Definition TestResult.cpp:122
TestResult::reset
virtual void reset()
Resets the stop flag.
Definition TestResult.cpp:34
TestResult::startSuite
virtual void startSuite(Test *test)
Informs TestListener that a test suite will be started.
Definition TestResult.cpp:92
TestResult::m_listeners
TestListeners m_listeners
Definition TestResult.h:133
TestResult::removeListener
virtual void removeListener(TestListener *listener)
Definition TestResult.cpp:138
TestResult::TestResult
TestResult(SynchronizationObject *syncObject=0)
Construct a TestResult.
Definition TestResult.cpp:15
TestResult::runTest
virtual void runTest(Test *test)
Run the specified test.
Definition TestResult.cpp:146
TestResult::startTest
virtual void startTest(Test *test)
Informs TestListener that a test will be started.
Definition TestResult.cpp:70
TestResult::addError
virtual void addError(Test *test, Exception *e)
Adds an error to the list of errors. The passed in exception caused the error.
Definition TestResult.cpp:42
TestResult::shouldStop
virtual bool shouldStop() const
Returns whether testing should be stopped.
Definition TestResult.cpp:114
TestResult::endTestRun
virtual void endTestRun(Test *test)
Definition TestResult.cpp:166
TestResult::endSuite
virtual void endSuite(Test *test)
Informs TestListener that a test suite was completed.
Definition TestResult.cpp:103
TestResult::TestResult
TestResult(const TestResult &other)
TestResult::m_stop
bool m_stop
Definition TestResult.h:135
TestResult::m_protectorChain
ProtectorChain * m_protectorChain
Definition TestResult.h:134
TestResult::TestListeners
std::deque< TestListener * > TestListeners
Definition TestResult.h:132

| Send comments to: CppUnit Developers