2012-04-29 18:52:25 +00:00
|
|
|
//
|
|
|
|
// TestSuite.cpp
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "CppUnit/TestSuite.h"
|
|
|
|
#include "CppUnit/TestResult.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace CppUnit {
|
|
|
|
|
|
|
|
|
|
|
|
// Deletes all tests in the suite.
|
|
|
|
void TestSuite::deleteContents()
|
|
|
|
{
|
|
|
|
for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Runs the tests and collects their result in a TestResult.
|
|
|
|
void TestSuite::run(TestResult *result)
|
|
|
|
{
|
|
|
|
for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
|
|
|
|
{
|
|
|
|
if (result->shouldStop ())
|
|
|
|
break;
|
|
|
|
|
|
|
|
Test *test = *it;
|
2018-05-21 22:02:25 +02:00
|
|
|
if (!setup().empty())
|
|
|
|
test->addSetup(setup());
|
2012-04-29 18:52:25 +00:00
|
|
|
test->run(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Counts the number of test cases that will be run by this test.
|
2019-10-18 15:09:38 +02:00
|
|
|
int TestSuite::countTestCases() const
|
2012-04-29 18:52:25 +00:00
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
|
2019-10-18 15:09:38 +02:00
|
|
|
for (std::vector<Test*>::const_iterator it = _tests.begin (); it != _tests.end (); ++it)
|
2012-04-29 18:52:25 +00:00
|
|
|
count += (*it)->countTestCases();
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace CppUnit
|