void RunnerGUI::showDetails(Q3ListViewItem *item) { if ( item == 0L ) return; QString name = fullName(item); if ( name.endsWith("()") ) name = fullName(item->parent()); Tester *tester = Runner::self()->registry().find(name.local8Bit()); if ( tester == 0L ) return; TestResults *res = 0L; if ( tester->inherits("KUnitTest::SlotTester") ) res = static_cast<SlotTester*>(tester)->results(item->text(g_nameColumn).local8Bit()); else res = tester->results(); if ( tester == 0L ) m_testerWidget->details()->setText("No test found with name: " + fullName(item)); else { Q3TextEdit *te = m_testerWidget->details(); te->clear(); te->append("<qt><a name=\"errors\"><font color=\"#990000\">Errors</font></a>:<br></qt>"); appendList(te, res->errorList()); te->append("<qt><br><hr><font color=\"#c2c939\">Expected to fail</font>:<br></qt>"); appendList(te, res->xfailList()); te->append("<qt><br><hr><font color=\"#BF00B5\">Unexpected Success</font>:<br></qt>"); appendList(te, res->xpassList()); te->append("<qt><br><hr><font color=\"#009900\">Success</font>:<br></qt>"); appendList(te, res->successList()); te->append("<qt><br><hr><font color=\"#F7A300\">Skipped</font>:<br></qt>"); appendList(te, res->skipList()); te->append("<qt><br><hr><font color=\"#000099\">Debug</font>:<br></qt>"); te->append(res->debugInfo()); te->scrollToAnchor("errors"); } }
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); }