const TestResult* TestRegistry::runTests(TestRunner *runner) { TestCase *tc = currentTC_; if (tc != 0) { tc = tc->getNext(); runner->run(tc,testCaseCount_); } testResult_.setTestCases(tc,testCaseCount_); return &testResult_; }
void TestRegistry::addTestCase(TestCase *testCase) { TestCase *tmp; if (currentTC_ == 0) { currentTC_ = testCase; currentTC_->setNext(currentTC_); } else { tmp = currentTC_; currentTC_ = testCase; currentTC_->setNext(tmp->getNext()); tmp->setNext(currentTC_); } testCaseCount_++; }
void DefaultTestPrinter::print( const TestResult *testResult ) { int failures; int successes; int errors; std::string state; std::string name; TestCase *testCase = testResult->getTestCases(); int size = testResult->getTestCaseCount(); printHeader( testResult ); if ( testResult->getTestCaseRanCount() == 0 ) { fprintf( output_, "No test ran\n" ); } for ( int i = 0;i < size;i++ ) { if ( testCase->ran() ) { name = testCase->getName(); failures = testCase->getFailuresCount(); successes = testCase->getSuccessesCount(); errors = testCase->getErrorsCount(); if ( failures > 0 || errors > 0 ) { state = "FAILED"; } else { state = "PASSED"; } fprintf( output_, "Test case \"%s\" %s with %d error(s), %d failure(s) and %d success(es):\n", name.c_str(), state.c_str(), errors, failures, successes ); printTests( testCase ); fprintf( output_, "\n" ); } testCase = testCase->getNext(); } }