Beispiel #1
0
    void RunnerGUI::addTestResult(const char *name, Tester *test)
    {
        QStringList scopes = QStringList::split("::", name);
        QString suite = scopes[0];

        // find the suite item
        Q3ListViewItem *item = 0L;
        for ( uint i = 0; i < scopes.count(); ++i )
            item = getItem(scopes[i], item);

        if ( test->inherits("KUnitTest::SlotTester") )
        {
            SlotTester *sltest = static_cast<SlotTester*>(test);
            TestResultsListIteratorType it(sltest->resultsList());
            Q3ListViewItem *slotItem = 0L;
            for ( ; it.current(); ++it)
            {
                slotItem = getItem(it.currentKey(), item);
                setSummary(slotItem, it.current());
            }
        }
        else
            setSummary(item, test->results());

        fillResultsLabel();
        m_testerWidget->progressBar()->setProgress(m_testerWidget->progressBar()->progress() + 1);
    }
Beispiel #2
0
    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);
    }