From 58c617c798c0d0db244735451acd316306068491 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 31 Jan 2012 14:07:58 +1000 Subject: Add testlib selftest for counting of test results. The test simply generates each possible pair of Pass, Fail and Skip results. At present the test simply serves to demonstrate the current shortcomings of testlib's plain text logging, namely: * If a test function passes for all data rows, that is counted as one pass, but each skipped or failed row counts as one skip or fail. * Only skipped and failed rows are reported individually in the test output. Passed rows are not reported, so it is impossible to see how many rows were executed. * A skip followed by a pass will be reported as an overall pass for the test function, but the same rows in reverse order will not report any overall result for the test function. Future commits will attempt to correct these problems. Task-number: QTBUG-22124 Change-Id: If8c7ea15fc43ba9a1bccd0e881c1efc18e705b25 Reviewed-by: Rohan McGovern --- tests/auto/testlib/selftests/counting/counting.pro | 7 + .../testlib/selftests/counting/tst_counting.cpp | 216 +++++++++++++++++++++ .../testlib/selftests/expected_counting.lightxml | 78 ++++++++ tests/auto/testlib/selftests/expected_counting.txt | 32 +++ tests/auto/testlib/selftests/expected_counting.xml | 81 ++++++++ .../testlib/selftests/expected_counting.xunitxml | 46 +++++ tests/auto/testlib/selftests/selftests.pri | 2 +- tests/auto/testlib/selftests/selftests.qrc | 4 + tests/auto/testlib/selftests/tst_selftests.cpp | 1 + 9 files changed, 466 insertions(+), 1 deletion(-) create mode 100644 tests/auto/testlib/selftests/counting/counting.pro create mode 100644 tests/auto/testlib/selftests/counting/tst_counting.cpp create mode 100644 tests/auto/testlib/selftests/expected_counting.lightxml create mode 100644 tests/auto/testlib/selftests/expected_counting.txt create mode 100644 tests/auto/testlib/selftests/expected_counting.xml create mode 100644 tests/auto/testlib/selftests/expected_counting.xunitxml (limited to 'tests/auto/testlib/selftests') diff --git a/tests/auto/testlib/selftests/counting/counting.pro b/tests/auto/testlib/selftests/counting/counting.pro new file mode 100644 index 0000000000..8aa2fe5753 --- /dev/null +++ b/tests/auto/testlib/selftests/counting/counting.pro @@ -0,0 +1,7 @@ +SOURCES += tst_counting.cpp +QT = core testlib + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = counting diff --git a/tests/auto/testlib/selftests/counting/tst_counting.cpp b/tests/auto/testlib/selftests/counting/tst_counting.cpp new file mode 100644 index 0000000000..6758b533bb --- /dev/null +++ b/tests/auto/testlib/selftests/counting/tst_counting.cpp @@ -0,0 +1,216 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class tst_Counting : public QObject +{ + Q_OBJECT + +private slots: + void testPassPass_data(); + void testPassPass(); + + void testPassSkip_data(); + void testPassSkip(); + + void testPassFail_data(); + void testPassFail(); + + void testSkipPass_data(); + void testSkipPass(); + + void testSkipSkip_data(); + void testSkipSkip(); + + void testSkipFail_data(); + void testSkipFail(); + + void testFailPass_data(); + void testFailPass(); + + void testFailSkip_data(); + void testFailSkip(); + + void testFailFail_data(); + void testFailFail(); + +private: + void helper(); +}; + +enum TestResult +{ + Pass, + Fail, + Skip +}; + +Q_DECLARE_METATYPE(TestResult); + +void tst_Counting::helper() +{ + QFETCH(TestResult, result); + + switch (result) { + case Pass: + QVERIFY(true); + break; + case Fail: + QVERIFY(false); + break; + case Skip: + QSKIP("Skipping"); + break; + } +} + +void tst_Counting::testPassPass_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Pass; + QTest::newRow("row 2") << Pass; +} + +void tst_Counting::testPassPass() +{ + helper(); +} + +void tst_Counting::testPassSkip_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Pass; + QTest::newRow("row 2") << Skip; +} + +void tst_Counting::testPassSkip() +{ + helper(); +} + +void tst_Counting::testPassFail_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Pass; + QTest::newRow("row 2") << Fail; +} + +void tst_Counting::testPassFail() +{ + helper(); +} + +void tst_Counting::testSkipPass_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Skip; + QTest::newRow("row 2") << Pass; +} + +void tst_Counting::testSkipPass() +{ + helper(); +} + +void tst_Counting::testSkipSkip_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Skip; + QTest::newRow("row 2") << Skip; +} + +void tst_Counting::testSkipSkip() +{ + helper(); +} + +void tst_Counting::testSkipFail_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Skip; + QTest::newRow("row 2") << Fail; +} + +void tst_Counting::testSkipFail() +{ + helper(); +} + +void tst_Counting::testFailPass_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Fail; + QTest::newRow("row 2") << Pass; +} + +void tst_Counting::testFailPass() +{ + helper(); +} + +void tst_Counting::testFailSkip_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Fail; + QTest::newRow("row 2") << Skip; +} + +void tst_Counting::testFailSkip() +{ + helper(); +} + +void tst_Counting::testFailFail_data() +{ + QTest::addColumn("result"); + QTest::newRow("row 1") << Fail; + QTest::newRow("row 2") << Fail; +} + +void tst_Counting::testFailFail() +{ + helper(); +} + +QTEST_MAIN(tst_Counting) +#include "tst_counting.moc" diff --git a/tests/auto/testlib/selftests/expected_counting.lightxml b/tests/auto/testlib/selftests/expected_counting.lightxml new file mode 100644 index 0000000000..f16abef128 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_counting.lightxml @@ -0,0 +1,78 @@ + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_counting.txt b/tests/auto/testlib/selftests/expected_counting.txt new file mode 100644 index 0000000000..adf80012c7 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_counting.txt @@ -0,0 +1,32 @@ +********* Start testing of tst_Counting ********* +Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +PASS : tst_Counting::initTestCase() +PASS : tst_Counting::testPassPass() +SKIP : tst_Counting::testPassSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(102)] +FAIL! : tst_Counting::testPassFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(99)] +SKIP : tst_Counting::testSkipPass(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(102)] +PASS : tst_Counting::testSkipPass() +SKIP : tst_Counting::testSkipSkip(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(102)] +SKIP : tst_Counting::testSkipSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(102)] +SKIP : tst_Counting::testSkipFail(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(102)] +FAIL! : tst_Counting::testSkipFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(99)] +FAIL! : tst_Counting::testFailPass(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(99)] +FAIL! : tst_Counting::testFailSkip(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(99)] +SKIP : tst_Counting::testFailSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(102)] +FAIL! : tst_Counting::testFailFail(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(99)] +FAIL! : tst_Counting::testFailFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(99)] +PASS : tst_Counting::cleanupTestCase() +Totals: 4 passed, 6 failed, 6 skipped +********* Finished testing of tst_Counting ********* diff --git a/tests/auto/testlib/selftests/expected_counting.xml b/tests/auto/testlib/selftests/expected_counting.xml new file mode 100644 index 0000000000..f5982d7052 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_counting.xml @@ -0,0 +1,81 @@ + + + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_counting.xunitxml b/tests/auto/testlib/selftests/expected_counting.xunitxml new file mode 100644 index 0000000000..c19a1612cb --- /dev/null +++ b/tests/auto/testlib/selftests/expected_counting.xunitxml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index f506c8c08c..95664c3793 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -4,4 +4,4 @@ SUBPROGRAMS = subtest warnings maxwarnings cmptest globaldata skip \ exceptionthrow qexecstringlist datatable commandlinedata\ benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \ benchliboptions xunit badxml longstring float printdatatags \ - printdatatagswithglobaltags findtestdata + printdatatagswithglobaltags findtestdata counting diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index fb303af2b5..d10aa56ceb 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -37,6 +37,10 @@ expected_commandlinedata.txt expected_commandlinedata.xml expected_commandlinedata.xunitxml + expected_counting.lightxml + expected_counting.txt + expected_counting.xml + expected_counting.xunitxml expected_crashes.lightxml expected_crashes.xml expected_crashes.xunitxml diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 7c2ca649c6..aaa58e092c 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -327,6 +327,7 @@ void tst_Selftests::runSubTest_data() << "benchliboptions" << "cmptest" << "commandlinedata" + << "counting" << "crashes" << "datatable" << "datetime" -- cgit v1.2.3