From 3dfdf34c1c3ce3a2348aedc4192956e5884a914b Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 12 Jan 2012 13:47:25 +1000 Subject: [PATCH] Improve coverage of expectfail selftest Add a test for the case where a call to QEXPECT_FAIL nominates a different data row from the current row, in which case the call to QEXPECT_FAIL should be ignored. Change-Id: Iff774b89f9374fa26105acdd8769177272a95229 Reviewed-by: Rohan McGovern --- .../testlib/selftests/expected_expectfail.lightxml | 19 +++++++++++-------- tests/auto/testlib/selftests/expected_expectfail.txt | 19 ++++++++++--------- tests/auto/testlib/selftests/expected_expectfail.xml | 19 +++++++++++-------- .../testlib/selftests/expected_expectfail.xunitxml | 3 ++- .../testlib/selftests/expectfail/tst_expectfail.cpp | 16 ++++++++++++++++ 5 files changed, 50 insertions(+), 26 deletions(-) diff --git a/tests/auto/testlib/selftests/expected_expectfail.lightxml b/tests/auto/testlib/selftests/expected_expectfail.lightxml index d2659fa..7668dc0 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.lightxml +++ b/tests/auto/testlib/selftests/expected_expectfail.lightxml @@ -9,7 +9,7 @@ - + @@ -21,41 +21,44 @@ - + - + - + - + - + - + - + + + + diff --git a/tests/auto/testlib/selftests/expected_expectfail.txt b/tests/auto/testlib/selftests/expected_expectfail.txt index 4fe3b51..bee54c6 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.txt +++ b/tests/auto/testlib/selftests/expected_expectfail.txt @@ -3,27 +3,28 @@ Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE PASS : tst_ExpectFail::initTestCase() QDEBUG : tst_ExpectFail::expectAndContinue() begin XFAIL : tst_ExpectFail::expectAndContinue() This should xfail - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(66)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(68)] QDEBUG : tst_ExpectFail::expectAndContinue() after PASS : tst_ExpectFail::expectAndContinue() QDEBUG : tst_ExpectFail::expectAndAbort() begin XFAIL : tst_ExpectFail::expectAndAbort() This should xfail - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(74)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(76)] PASS : tst_ExpectFail::expectAndAbort() FAIL! : tst_ExpectFail::expectTwice() Already expecting a fail - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(83)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(85)] XFAIL : tst_ExpectFail::xfailWithQString() A string - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(93)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(95)] XFAIL : tst_ExpectFail::xfailWithQString() Bug 5 (The message) - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(98)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(100)] PASS : tst_ExpectFail::xfailWithQString() XPASS : tst_ExpectFail::xpass() 'true' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(104)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(106)] XFAIL : tst_ExpectFail::dataDrivenTest(Abort) This test should xfail - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(137)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(139)] XFAIL : tst_ExpectFail::dataDrivenTest(Continue) This test should xfail - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(137)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(139)] PASS : tst_ExpectFail::dataDrivenTest() +PASS : tst_ExpectFail::expectOnWrongRow() PASS : tst_ExpectFail::cleanupTestCase() -Totals: 6 passed, 2 failed, 0 skipped +Totals: 7 passed, 2 failed, 0 skipped ********* Finished testing of tst_ExpectFail ********* diff --git a/tests/auto/testlib/selftests/expected_expectfail.xml b/tests/auto/testlib/selftests/expected_expectfail.xml index a719928..5764d6d 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.xml +++ b/tests/auto/testlib/selftests/expected_expectfail.xml @@ -11,7 +11,7 @@ - + @@ -23,41 +23,44 @@ - + - + - + - + - + - + - + + + + diff --git a/tests/auto/testlib/selftests/expected_expectfail.xunitxml b/tests/auto/testlib/selftests/expected_expectfail.xunitxml index e93cb03..511b522 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.xunitxml +++ b/tests/auto/testlib/selftests/expected_expectfail.xunitxml @@ -1,5 +1,5 @@ - + @@ -28,6 +28,7 @@ + diff --git a/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp b/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp index 73d3e0c..4b9f360 100644 --- a/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp +++ b/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp @@ -57,6 +57,8 @@ private slots: void xpass() const; void dataDrivenTest_data() const; void dataDrivenTest() const; + void expectOnWrongRow_data() const; + void expectOnWrongRow() const; }; void tst_ExpectFail::expectAndContinue() const @@ -142,5 +144,19 @@ void tst_ExpectFail::dataDrivenTest() const QCOMPARE(failMode, QTest::Continue); } +void tst_ExpectFail::expectOnWrongRow_data() const +{ + QTest::addColumn("dummy"); + + QTest::newRow("right row") << 0; +} + +void tst_ExpectFail::expectOnWrongRow() const +{ + // QEXPECT_FAIL for a row that is not the current row should be ignored. + QEXPECT_FAIL("wrong row", "This xfail should be ignored", Abort); + QVERIFY(true); +} + QTEST_MAIN(tst_ExpectFail) #include "tst_expectfail.moc" -- 2.7.4