21 for (std::list<tarch::tests::TestCase*>::iterator p =
_testCases.begin(); p!=
_testCases.end(); p++ ) {
23 delete currentTestCase;
25 for (std::map<std::string, TreeTestCaseCollection*>::iterator p =
_subTests.begin(); p!=
_subTests.end(); p++ ) {
27 delete currentTestCase;
34 return testCaseName.rfind(
"::") == std::string::npos;
39 std::string result = testCaseName.substr(0, testCaseName.find(
"::"));
50 std::string result = testCaseName.substr(testCaseName.find(
"::")+2);
62 std::string logInformation;
64 logInformation =
"running test case collection \"" + prefix +
_testCaseName +
"\" ...";
67 logInformation =
"running test case collection ...";
75 logInformation +=
"... WARNING: no tests defined ... ";
80 for (std::map<std::string, TreeTestCaseCollection*>::iterator p =
_subTests.begin(); p!=
_subTests.end(); p++ ) {
81 (*p).second->run( fullQualifiedName );
82 _errors += (*p).second->getNumberOfErrors();
85 for (std::list<tarch::tests::TestCase*>::iterator p =
_testCases.begin(); p!=
_testCases.end(); p++ ) {
87 logInformation +=
".";
88 currentTestCase->
run();
90 if (additionalErrors>0) {
91 logInformation +=
"x";
95 logInformation +=
".";
100 logInformation +=
" pass (no local tests)";
103 logInformation +=
" pass (no local tests, subtests all successful)";
106 logInformation +=
" ok (1 test)";
109 logInformation +=
" ok (" + std::to_string(
_testCases.size()) +
" tests)";
112 logInformation +=
" failed";
116 logInfo(
"run()",logInformation );
135 std::pair<std::string,TreeTestCaseCollection*>(
136 firstPartOfIdentifier,
141 _subTests[firstPartOfIdentifier]->addTestCase(secondPartOfIdentifier, testCase);
#define assertion2(expr, param0, param1)
#define assertion3(expr, param0, param1, param2)
#define logInfo(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Represents one test case.
int getNumberOfErrors() const
virtual void run()=0
This routine is triggered by the TestCaseCollection.
int _errors
Error counter.
std::string getTestCaseName() const
const std::string _testCaseName
Name of the test case.
static std::string getRemainingPathWithoutIdentifier(const std::string &testCaseName)
static bool isNameWithoutHierarchy(const std::string &testCaseName)
void addTestCase(const std::string &fullQualifiedPath, TestCase *testCase)
Adds a new test case.
virtual void run()
Runs all test cases assigned.
static tarch::logging::Log _log
Log interface the class writes to.
virtual ~TreeTestCaseCollection()
Destructor.
bool _deleteTestCases
Tells whether the testcases contained should be deleted uppon destruction of this object.
bool _writeToLog
Tells the collection wheather to log a progression bar.
std::list< TestCase * > _testCases
Sequence of test cases that are executes on a run() call.
TreeTestCaseCollection(const std::string &testCaseCollectionName="", bool deleteTestCases=true, bool writeToLog=true)
Creates a test case collection.
std::map< std::string, TreeTestCaseCollection * > _subTests
static std::string getFirstIdentifierInHierarchy(const std::string &testCaseName)