diff --git a/tests/auto/testlib/selftests/expected_expectfail.lightxml b/tests/auto/testlib/selftests/expected_expectfail.lightxml
index f983a870d3..23fb4bf268 100644
--- a/tests/auto/testlib/selftests/expected_expectfail.lightxml
+++ b/tests/auto/testlib/selftests/expected_expectfail.lightxml
@@ -9,7 +9,7 @@
-
+
@@ -21,20 +21,31 @@
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/auto/testlib/selftests/expected_expectfail.txt b/tests/auto/testlib/selftests/expected_expectfail.txt
index 77b01dfd86..a111a0fefe 100644
--- a/tests/auto/testlib/selftests/expected_expectfail.txt
+++ b/tests/auto/testlib/selftests/expected_expectfail.txt
@@ -3,18 +3,23 @@ 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(27)]
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(64)]
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(35)]
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(72)]
PASS : tst_ExpectFail::expectAndAbort()
XFAIL : tst_ExpectFail::xfailWithQString() A string
- Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(42)]
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(79)]
XFAIL : tst_ExpectFail::xfailWithQString() Bug 5 (The message)
- Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(47)]
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(84)]
PASS : tst_ExpectFail::xfailWithQString()
+XFAIL : tst_ExpectFail::dataDrivenTest(Abort) This test should xfail
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(113)]
+XFAIL : tst_ExpectFail::dataDrivenTest(Continue) This test should xfail
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(113)]
+PASS : tst_ExpectFail::dataDrivenTest()
PASS : tst_ExpectFail::cleanupTestCase()
-Totals: 5 passed, 0 failed, 0 skipped
+Totals: 6 passed, 0 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 12a1d5cdbf..4a10d3051a 100644
--- a/tests/auto/testlib/selftests/expected_expectfail.xml
+++ b/tests/auto/testlib/selftests/expected_expectfail.xml
@@ -11,7 +11,7 @@
-
+
@@ -23,20 +23,31 @@
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/auto/testlib/selftests/expected_expectfail.xunitxml b/tests/auto/testlib/selftests/expected_expectfail.xunitxml
index 32a5cfca81..0584b54af2 100644
--- a/tests/auto/testlib/selftests/expected_expectfail.xunitxml
+++ b/tests/auto/testlib/selftests/expected_expectfail.xunitxml
@@ -1,5 +1,5 @@
-
+
@@ -18,6 +18,10 @@
+
+
+
+
@@ -27,5 +31,7 @@
+
+
diff --git a/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp b/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp
index 6df919a9a0..28b00dccf7 100644
--- a/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp
+++ b/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp
@@ -43,6 +43,8 @@
#include
#include
+Q_DECLARE_METATYPE(QTest::TestFailMode)
+
class tst_ExpectFail: public QObject
{
Q_OBJECT
@@ -51,6 +53,8 @@ private slots:
void expectAndContinue() const;
void expectAndAbort() const;
void xfailWithQString() const;
+ void dataDrivenTest_data() const;
+ void dataDrivenTest() const;
};
void tst_ExpectFail::expectAndContinue() const
@@ -80,6 +84,39 @@ void tst_ExpectFail::xfailWithQString() const
QVERIFY(false);
}
-QTEST_MAIN(tst_ExpectFail)
+void tst_ExpectFail::dataDrivenTest_data() const
+{
+ QTest::addColumn("shouldPass");
+ QTest::addColumn("failMode");
+ QTest::newRow("Pass 1") << true << QTest::Abort;
+ QTest::newRow("Pass 2") << true << QTest::Continue;
+ QTest::newRow("Abort") << false << QTest::Abort;
+ QTest::newRow("Continue") << false << QTest::Continue;
+}
+
+void tst_ExpectFail::dataDrivenTest() const
+{
+ QFETCH(bool, shouldPass);
+ QFETCH(QTest::TestFailMode, failMode);
+
+ // You can't pass a variable as the last parameter of QEXPECT_FAIL,
+ // because the macro adds "QTest::" in front of the last parameter.
+ // That is why the following code appears to be a little strange.
+ if (!shouldPass) {
+ if (failMode == QTest::Abort)
+ QEXPECT_FAIL(QTest::currentDataTag(), "This test should xfail", Abort);
+ else
+ QEXPECT_FAIL(QTest::currentDataTag(), "This test should xfail", Continue);
+ }
+
+ QVERIFY(shouldPass);
+
+ // If we get here, we either expected to pass or we expected to
+ // fail and the failure mode was Continue.
+ if (!shouldPass)
+ QCOMPARE(failMode, QTest::Continue);
+}
+
+QTEST_MAIN(tst_ExpectFail)
#include "tst_expectfail.moc"