1#ifndef CPPUNIT_TESTRESULTCOLLECTOR_H
2#define CPPUNIT_TESTRESULTCOLLECTOR_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/TestSucessListener.h>
12#include <deque>
13
14
15namespace CppUnit
16{
17
18
19#if CPPUNIT_NEED_DLL_DECL
20  template class CPPUNIT_API deque<TestFailure *>;
21  template class CPPUNIT_API deque<Test *>;
22#endif
23
24
25/*! \brief Collects test result.
26 * \ingroup WritingTestResult
27 * \ingroup BrowsingCollectedTestResult
28 *
29 * A TestResultCollector is a TestListener which collects the results of executing
30 * a test case. It is an instance of the Collecting Parameter pattern.
31 *
32 * The test framework distinguishes between failures and errors.
33 * A failure is anticipated and checked for with assertions. Errors are
34 * unanticipated problems signified by exceptions that are not generated
35 * by the framework.
36 * \see TestListener, TestFailure.
37 */
38class CPPUNIT_API TestResultCollector : public TestSucessListener
39{
40public:
41  typedef std::deque<TestFailure *> TestFailures;
42  typedef std::deque<Test *> Tests;
43
44
45  /*! Constructs a TestResultCollector object.
46   */
47  TestResultCollector( SynchronizationObject *syncObject = 0 );
48
49  /// Destructor.
50  virtual ~TestResultCollector();
51
52  void startTest( Test *test );
53  void addFailure( const TestFailure &failure );
54
55  virtual void reset();
56
57  virtual int runTests() const;
58  virtual int testErrors() const;
59  virtual int testFailures() const;
60  virtual int testFailuresTotal() const;
61
62  virtual const TestFailures& failures() const;
63  virtual const Tests &tests() const;
64
65protected:
66  Tests m_tests;
67  TestFailures m_failures;
68  int m_testErrors;
69
70private:
71  /// Prevents the use of the copy constructor.
72  TestResultCollector( const TestResultCollector &copy );
73
74  /// Prevents the use of the copy operator.
75  void operator =( const TestResultCollector &copy );
76};
77
78
79
80} //  namespace CppUnit
81
82
83#if CPPUNIT_NEED_DLL_DECL
84#pragma warning( pop )
85#endif
86
87
88#endif  // CPPUNIT_TESTRESULTCOLLECTOR_H
89