TestSuite.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef CPPUNIT_TESTSUITE_H // -*- C++ -*-
  2. #define CPPUNIT_TESTSUITE_H
  3. #include <cppunit/Portability.h>
  4. #if CPPUNIT_NEED_DLL_DECL
  5. #pragma warning( push )
  6. #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
  7. #endif
  8. #include <cppunit/TestComposite.h>
  9. #include <cppunit/portability/CppUnitVector.h>
  10. CPPUNIT_NS_BEGIN
  11. #if CPPUNIT_NEED_DLL_DECL
  12. // template class CPPUNIT_API std::vector<Test *>;
  13. #endif
  14. /*! \brief A Composite of Tests.
  15. * \ingroup CreatingTestSuite
  16. *
  17. * It runs a collection of test cases. Here is an example.
  18. * \code
  19. * CppUnit::TestSuite *suite= new CppUnit::TestSuite();
  20. * suite->addTest(new CppUnit::TestCaller<MathTest> (
  21. * "testAdd", testAdd));
  22. * suite->addTest(new CppUnit::TestCaller<MathTest> (
  23. * "testDivideByZero", testDivideByZero));
  24. * \endcode
  25. * Note that \link TestSuite TestSuites \endlink assume lifetime
  26. * control for any tests added to them.
  27. *
  28. * TestSuites do not register themselves in the TestRegistry.
  29. * \see Test
  30. * \see TestCaller
  31. */
  32. class CPPUNIT_API TestSuite : public TestComposite
  33. {
  34. public:
  35. /*! Constructs a test suite with the specified name.
  36. */
  37. TestSuite( std::string name = "" );
  38. ~TestSuite();
  39. /*! Adds the specified test to the suite.
  40. * \param test Test to add. Must not be \c NULL.
  41. */
  42. void addTest( Test *test );
  43. /*! Returns the list of the tests (DEPRECATED).
  44. * \deprecated Use getChildTestCount() & getChildTestAt() of the
  45. * TestComposite interface instead.
  46. * \return Reference on a vector that contains the tests of the suite.
  47. */
  48. const CppUnitVector<Test *> &getTests() const;
  49. /*! Destroys all the tests of the suite.
  50. */
  51. virtual void deleteContents();
  52. int getChildTestCount() const;
  53. Test *doGetChildTestAt( int index ) const;
  54. private:
  55. CppUnitVector<Test *> m_tests;
  56. };
  57. CPPUNIT_NS_END
  58. #if CPPUNIT_NEED_DLL_DECL
  59. #pragma warning( pop )
  60. #endif
  61. #endif // CPPUNIT_TESTSUITE_H