diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2012-02-03 10:22:13 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-09 04:07:33 +0100 |
commit | 95d0b27711c2f75af233c9a083c9818400db0957 (patch) | |
tree | 2f9c6098376e9549cf7221f08aacfb521d4bba98 /tests/auto/testlib | |
parent | 931f4501a6f5fb77c9bd9f48b63a8ee88cba4355 (diff) |
testlib: Add selftests for skip and fail inside cleanupTestCase().
Change-Id: I9bbe774c3259338d452cd1eb1a6f37a85db15921
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/testlib')
15 files changed, 261 insertions, 1 deletions
diff --git a/tests/auto/testlib/selftests/expected_failcleanup.lightxml b/tests/auto/testlib/selftests/expected_failcleanup.lightxml new file mode 100644 index 0000000000..83ce7a7b15 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_failcleanup.lightxml @@ -0,0 +1,15 @@ +<Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> +</Environment> +<TestFunction name="initTestCase"> +<Incident type="pass" file="" line="0" /> +</TestFunction> +<TestFunction name="aTestFunction"> +<Incident type="pass" file="" line="0" /> +</TestFunction> +<TestFunction name="cleanupTestCase"> +<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp" line="59"> + <Description><![CDATA['false' returned FALSE. (Fail inside cleanupTestCase)]]></Description> +</Incident> +</TestFunction> diff --git a/tests/auto/testlib/selftests/expected_failcleanup.txt b/tests/auto/testlib/selftests/expected_failcleanup.txt new file mode 100644 index 0000000000..08c10b1823 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_failcleanup.txt @@ -0,0 +1,8 @@ +********* Start testing of tst_FailCleanup ********* +Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +PASS : tst_FailCleanup::initTestCase() +PASS : tst_FailCleanup::aTestFunction() +FAIL! : tst_FailCleanup::cleanupTestCase() 'false' returned FALSE. (Fail inside cleanupTestCase) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp(59)] +Totals: 2 passed, 1 failed, 0 skipped +********* Finished testing of tst_FailCleanup ********* diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xml b/tests/auto/testlib/selftests/expected_failcleanup.xml new file mode 100644 index 0000000000..5d0d2c5751 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_failcleanup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<TestCase name="tst_FailCleanup"> +<Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> +</Environment> +<TestFunction name="initTestCase"> +<Incident type="pass" file="" line="0" /> +</TestFunction> +<TestFunction name="aTestFunction"> +<Incident type="pass" file="" line="0" /> +</TestFunction> +<TestFunction name="cleanupTestCase"> +<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp" line="59"> + <Description><![CDATA['false' returned FALSE. (Fail inside cleanupTestCase)]]></Description> +</Incident> +</TestFunction> +</TestCase> diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xunitxml b/tests/auto/testlib/selftests/expected_failcleanup.xunitxml new file mode 100644 index 0000000000..6e35566be8 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_failcleanup.xunitxml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<testsuite errors="0" failures="1" tests="3" name="tst_FailCleanup"> + <properties> + <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> + <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + </properties> + <testcase result="pass" name="initTestCase"/> + <testcase result="pass" name="aTestFunction"/> + <testcase result="fail" name="cleanupTestCase"> + <failure message="'false' returned FALSE. (Fail inside cleanupTestCase)" result="fail"/> + </testcase> + <system-err/> +</testsuite> diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.lightxml b/tests/auto/testlib/selftests/expected_skipcleanup.lightxml new file mode 100644 index 0000000000..d2bc3b766e --- /dev/null +++ b/tests/auto/testlib/selftests/expected_skipcleanup.lightxml @@ -0,0 +1,15 @@ +<Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> +</Environment> +<TestFunction name="initTestCase"> +<Incident type="pass" file="" line="0" /> +</TestFunction> +<TestFunction name="aTestFunction"> +<Incident type="pass" file="" line="0" /> +</TestFunction> +<TestFunction name="cleanupTestCase"> +<Message type="skip" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp" line="59"> + <Description><![CDATA[Skip inside cleanupTestCase.]]></Description> +</Message> +</TestFunction> diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.txt b/tests/auto/testlib/selftests/expected_skipcleanup.txt new file mode 100644 index 0000000000..c97f31c2a9 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_skipcleanup.txt @@ -0,0 +1,8 @@ +********* Start testing of tst_SkipCleanup ********* +Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +PASS : tst_SkipCleanup::initTestCase() +PASS : tst_SkipCleanup::aTestFunction() +SKIP : tst_SkipCleanup::cleanupTestCase() Skip inside cleanupTestCase. + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp(59)] +Totals: 2 passed, 0 failed, 1 skipped +********* Finished testing of tst_SkipCleanup ********* diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xml b/tests/auto/testlib/selftests/expected_skipcleanup.xml new file mode 100644 index 0000000000..8fbfc7711c --- /dev/null +++ b/tests/auto/testlib/selftests/expected_skipcleanup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<TestCase name="tst_SkipCleanup"> +<Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> +</Environment> +<TestFunction name="initTestCase"> +<Incident type="pass" file="" line="0" /> +</TestFunction> +<TestFunction name="aTestFunction"> +<Incident type="pass" file="" line="0" /> +</TestFunction> +<TestFunction name="cleanupTestCase"> +<Message type="skip" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp" line="59"> + <Description><![CDATA[Skip inside cleanupTestCase.]]></Description> +</Message> +</TestFunction> +</TestCase> diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml b/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml new file mode 100644 index 0000000000..b8f67e2d07 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<testsuite errors="1" failures="0" tests="3" name="tst_SkipCleanup"> + <properties> + <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> + <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + </properties> + <testcase result="pass" name="initTestCase"/> + <testcase result="pass" name="aTestFunction"/> + <testcase name="cleanupTestCase"> + <!-- message="Skip inside cleanupTestCase." type="skip" --> + </testcase> + <system-err> +<![CDATA[Skip inside cleanupTestCase.]]> + </system-err> +</testsuite> diff --git a/tests/auto/testlib/selftests/failcleanup/failcleanup.pro b/tests/auto/testlib/selftests/failcleanup/failcleanup.pro new file mode 100644 index 0000000000..426d7cc45b --- /dev/null +++ b/tests/auto/testlib/selftests/failcleanup/failcleanup.pro @@ -0,0 +1,7 @@ +SOURCES += tst_failcleanup.cpp +QT = core testlib + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = failcleanup diff --git a/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp b/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp new file mode 100644 index 0000000000..a1b3b2d15a --- /dev/null +++ b/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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 <QtTest/QtTest> + +class tst_FailCleanup: public QObject +{ +Q_OBJECT +private slots: + void aTestFunction() const; + void cleanupTestCase() const; +}; + +void tst_FailCleanup::aTestFunction() const +{ + QVERIFY(true); +} + +void tst_FailCleanup::cleanupTestCase() const +{ + QVERIFY2(false, "Fail inside cleanupTestCase"); +} + +QTEST_APPLESS_MAIN(tst_FailCleanup) +#include "tst_failcleanup.moc" diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 95664c3793..9d4b2bd600 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 counting + printdatatagswithglobaltags findtestdata counting skipcleanup failcleanup diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index d10aa56ceb..f882068f6d 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -64,6 +64,10 @@ <file>expected_expectfail.txt</file> <file>expected_expectfail.xml</file> <file>expected_expectfail.xunitxml</file> + <file>expected_failcleanup.lightxml</file> + <file>expected_failcleanup.txt</file> + <file>expected_failcleanup.xml</file> + <file>expected_failcleanup.xunitxml</file> <file>expected_failinit.lightxml</file> <file>expected_failinit.txt</file> <file>expected_failinit.xml</file> @@ -108,6 +112,10 @@ <file>expected_skip.txt</file> <file>expected_skip.xml</file> <file>expected_skip.xunitxml</file> + <file>expected_skipcleanup.lightxml</file> + <file>expected_skipcleanup.txt</file> + <file>expected_skipcleanup.xml</file> + <file>expected_skipcleanup.xunitxml</file> <file>expected_skipinit.lightxml</file> <file>expected_skipinit.txt</file> <file>expected_skipinit.xml</file> diff --git a/tests/auto/testlib/selftests/skipcleanup/skipcleanup.pro b/tests/auto/testlib/selftests/skipcleanup/skipcleanup.pro new file mode 100644 index 0000000000..f98cda7596 --- /dev/null +++ b/tests/auto/testlib/selftests/skipcleanup/skipcleanup.pro @@ -0,0 +1,7 @@ +SOURCES += tst_skipcleanup.cpp +QT = core testlib + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = skipcleanup diff --git a/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp b/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp new file mode 100644 index 0000000000..262aefa982 --- /dev/null +++ b/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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 <QtTest/QtTest> + +class tst_SkipCleanup: public QObject +{ +Q_OBJECT +private slots: + void aTestFunction() const; + void cleanupTestCase() const; +}; + +void tst_SkipCleanup::aTestFunction() const +{ + QVERIFY(true); +} + +void tst_SkipCleanup::cleanupTestCase() const +{ + QSKIP("Skip inside cleanupTestCase."); +} + +QTEST_APPLESS_MAIN(tst_SkipCleanup) +#include "tst_skipcleanup.moc" diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index aaa58e092c..dc7966b82b 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -338,6 +338,7 @@ void tst_Selftests::runSubTest_data() << "exceptionthrow" #endif << "expectfail" + << "failcleanup" << "failinit" << "failinitdata" #if !defined(Q_OS_WIN) @@ -354,6 +355,7 @@ void tst_Selftests::runSubTest_data() << "qexecstringlist" << "singleskip" << "skip" + << "skipcleanup" << "skipinit" << "skipinitdata" << "sleep" |