void Runner::runTest(const char *name) { Tester *test = m_registry.find(name); if ( test == 0L ) return; if ( s_debugCapturingEnabled ) { cout << "KUnitTest_Debug_Start[" << name << "]" << endl; } test->results()->clear(); test->allTests(); if ( s_debugCapturingEnabled ) { cout << "KUnitTest_Debug_End[" << name << "]" << endl << endl << flush; } int numPass = 0; int numFail = 0; int numXFail = 0; int numXPass = 0; int numSkip = 0; QStringList xpassList; QStringList errorList; QStringList xfailList; QStringList skipList; if ( test->inherits("KUnitTest::SlotTester") ) { SlotTester *sltest = static_cast<SlotTester*>(test); TestResultsListIteratorType it(sltest->resultsList()); for ( ; it.current(); ++it) { numPass += it.current()->passed() + it.current()->xpasses(); numFail += it.current()->errors() + it.current()->xfails(); numXFail += it.current()->xfails(); numXPass += it.current()->xpasses(); numSkip += it.current()->skipped(); globalSteps += it.current()->testsFinished(); xpassList += it.current()->xpassList(); errorList += it.current()->errorList(); xfailList += it.current()->xfailList(); skipList += it.current()->skipList(); } } else { numPass= test->results()->passed() + test->results()->xpasses(); numFail= test->results()->errors() + test->results()->xfails(); numXFail = test->results()->xfails(); numXPass = test->results()->xpasses(); numSkip= test->results()->skipped(); globalSteps += test->results()->testsFinished(); xpassList += test->results()->xpassList(); errorList += test->results()->errorList(); xfailList += test->results()->xfailList(); skipList += test->results()->skipList(); } globalPasses += numPass; globalFails += numFail; globalXFails += numXFail; globalXPasses += numXPass; globalSkipped += numSkip; cout << name << " - "; cout << numPass << " test" << ( ( 1 == numPass )?"":"s") << " passed"; if ( 0 < xpassList.count() ) { cout << " (" << numXPass << " unexpected pass" << ( ( 1 == numXPass )?"":"es") << ")"; } cout << ", " << numFail << " test" << ( ( 1 == numFail )?"":"s") << " failed"; if ( 0 < numXFail ) { cout << " (" << numXFail << " expected failure" << ( ( 1 == numXFail )?"":"s") << ")"; } if ( 0 < numSkip ) { cout << "; also " << numSkip << " skipped"; } cout << endl; if ( 0 < numXPass ) { cout << " Unexpected pass" << ( ( 1 == numXPass )?"":"es") << ":" << endl; QStringList list = xpassList; for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < (numFail - numXFail) ) { cout << " Unexpected failure" << ( ( 1 == numFail )?"":"s") << ":" << endl; QStringList list = errorList; for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < numXFail ) { cout << " Expected failure" << ( ( 1 == numXFail)?"":"s") << ":" << endl; QStringList list = xfailList; for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < numSkip ) { cout << " Skipped test" << ( ( 1 == numSkip )?"":"s") << ":" << endl; QStringList list = skipList; for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } cout << endl; emit finished(name, test); }
int KUnitTest::runTests() { int globalSteps = 0; int globalPasses = 0; int globalFails = 0; int globalXFails = 0; int globalXPasses = 0; int globalSkipped = 0; cout << "# Running normal tests... #" << endl << endl; QAsciiDictIterator<Tester> it( m_tests ); for( ; it.current(); ++it ) { Tester* test = it.current(); test->allTests(); cout << it.currentKey() << " - "; int numPass = test->testsFinished() - ( test->errorList().count() + test->xfailList().count() + test->skipList().count() ); int numFail = test->errorList().count() + test->xfailList().count(); int numXFail = test->xfailList().count(); int numXPass = test->xpassList().count(); int numSkip = test->skipList().count(); globalSteps += test->testsFinished(); globalPasses += numPass; globalFails += numFail; globalXFails += numXFail; globalXPasses += numXPass; globalSkipped += numSkip; cout << numPass << " test" << ( ( 1 == numPass )?"":"s") << " passed"; if ( 0 < test->xpassList().count() ) { cout << " (" << numXPass << " unexpected pass" << ( ( 1 == numXPass )?"":"es") << ")"; } cout << ", " << numFail << " test" << ( ( 1 == numFail )?"":"s") << " failed"; if ( 0 < numXFail ) { cout << " (" << numXFail << " expected failure" << ( ( 1 == numXFail )?"":"s") << ")"; } if ( 0 < numSkip ) { cout << "; also " << numSkip << " skipped"; } cout << endl; if ( 0 < numXPass ) { cout << " Unexpected pass" << ( ( 1 == numXPass )?"":"es") << ":" << endl; QStringList list = test->xpassList(); for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < (numFail - numXFail) ) { cout << " Unexpected failure" << ( ( 1 == numFail )?"":"s") << ":" << endl; QStringList list = test->errorList(); for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < numXFail ) { cout << " Expected failure" << ( ( 1 == numXFail)?"":"s") << ":" << endl; QStringList list = test->xfailList(); for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < numSkip ) { cout << " Skipped test" << ( ( 1 == numSkip )?"":"s") << ":" << endl; QStringList list = test->skipList(); for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } cout << endl; } cout << "# Done with normal tests:" << endl; cout << " Total test cases: " << m_tests.count() << endl; cout << " Total test steps : " << globalSteps << endl; cout << " Total passed test steps (including unexpected) : " << globalPasses << endl; cout << " Total unexpected passed test steps : " << globalXPasses << endl; cout << " Total failed test steps (including expected) : " << globalFails << endl; cout << " Total expected failed test steps : " << globalXFails << endl; cout << " Total skipped test steps : " << globalSkipped << endl; return m_tests.count(); }