TestSuite.cpp 944 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // TestSuite.cpp
  3. //
  4. #include "CppUnit/TestSuite.h"
  5. #include "CppUnit/TestResult.h"
  6. namespace CppUnit {
  7. // Deletes all tests in the suite.
  8. void TestSuite::deleteContents()
  9. {
  10. for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
  11. delete *it;
  12. }
  13. // Runs the tests and collects their result in a TestResult.
  14. void TestSuite::run(TestResult *result, const Test::Callback& callback)
  15. {
  16. for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
  17. {
  18. if (result->shouldStop ())
  19. break;
  20. Test *test = *it;
  21. if (!setup().empty())
  22. test->addSetup(setup());
  23. test->run(result, callback);
  24. }
  25. }
  26. // Counts the number of test cases that will be run by this test.
  27. int TestSuite::countTestCases() const
  28. {
  29. int count = 0;
  30. for (std::vector<Test*>::const_iterator it = _tests.begin (); it != _tests.end (); ++it)
  31. count += (*it)->countTestCases();
  32. return count;
  33. }
  34. } // namespace CppUnit