TestResultCollector.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef CPPUNIT_TESTRESULTCOLLECTOR_H
  2. #define CPPUNIT_TESTRESULTCOLLECTOR_H
  3. #include <cppunit/Portability.h>
  4. #if CPPUNIT_NEED_DLL_DECL
  5. #pragma warning( push )
  6. #pragma warning( disable: 4251 4660 ) // X needs to have dll-interface to be used by clients of class Z
  7. #endif
  8. #include <cppunit/TestSuccessListener.h>
  9. #include <cppunit/portability/CppUnitDeque.h>
  10. CPPUNIT_NS_BEGIN
  11. #if CPPUNIT_NEED_DLL_DECL
  12. // template class CPPUNIT_API std::deque<TestFailure *>;
  13. // template class CPPUNIT_API std::deque<Test *>;
  14. #endif
  15. /*! \brief Collects test result.
  16. * \ingroup WritingTestResult
  17. * \ingroup BrowsingCollectedTestResult
  18. *
  19. * A TestResultCollector is a TestListener which collects the results of executing
  20. * a test case. It is an instance of the Collecting Parameter pattern.
  21. *
  22. * The test framework distinguishes between failures and errors.
  23. * A failure is anticipated and checked for with assertions. Errors are
  24. * unanticipated problems signified by exceptions that are not generated
  25. * by the framework.
  26. * \see TestListener, TestFailure.
  27. */
  28. class CPPUNIT_API TestResultCollector : public TestSuccessListener
  29. {
  30. public:
  31. typedef CppUnitDeque<TestFailure *> TestFailures;
  32. typedef CppUnitDeque<Test *> Tests;
  33. /*! Constructs a TestResultCollector object.
  34. */
  35. TestResultCollector( SynchronizationObject *syncObject = 0 );
  36. /// Destructor.
  37. virtual ~TestResultCollector();
  38. void startTest( Test *test );
  39. void addFailure( const TestFailure &failure );
  40. virtual void reset();
  41. virtual int runTests() const;
  42. virtual int testErrors() const;
  43. virtual int testFailures() const;
  44. virtual int testFailuresTotal() const;
  45. virtual const TestFailures& failures() const;
  46. virtual const Tests &tests() const;
  47. protected:
  48. void freeFailures();
  49. Tests m_tests;
  50. TestFailures m_failures;
  51. int m_testErrors;
  52. private:
  53. /// Prevents the use of the copy constructor.
  54. TestResultCollector( const TestResultCollector &copy );
  55. /// Prevents the use of the copy operator.
  56. void operator =( const TestResultCollector &copy );
  57. };
  58. CPPUNIT_NS_END
  59. #if CPPUNIT_NEED_DLL_DECL
  60. #pragma warning( pop )
  61. #endif
  62. #endif // CPPUNIT_TESTRESULTCOLLECTOR_H