summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/selftests/expectfail
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2012-02-01 15:42:00 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-08 03:13:21 +0100
commitda18ada6bf60e0a6724ee55abb619d367f8c4633 (patch)
tree0900a1ad36240032eaa76567f7ddeb71d4737633 /tests/auto/testlib/selftests/expectfail
parent684a1559f0de4354cd9427e4c9a86e4a6a4e238a (diff)
testlib: Clear expected failures after every data row.
Previously, expected failures were only cleared at the end of each test function, i.e. after all data rows were finished. This meant that if a data-driven test function called QEXPECT_FAIL and then didn't perform any further verification steps to trigger the expected failure, the expected failure would be carried over to the next data row, probably causing the first verification step in the test function to XPASS (with a seemingly irrelevant error message) for the next data row. This commit adds the new function QTestResult::finishedCurrentTestData() to cleanup after each data row is executed. This function treats calls to QEXPECT_FAIL without subsequent verification steps as a test failure. This commit also adds a regression test to demonstrate that expected failures can no longer be carried over from one data row to another. If run against the previous version of testlib, the new test would report a pass instead of an error. Change-Id: Ida5c7f080815b0dca9531131fed582b0918334cb Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/testlib/selftests/expectfail')
-rw-r--r--tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp b/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp
index 3a000ba182..56895b3801 100644
--- a/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp
+++ b/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp
@@ -60,6 +60,8 @@ private slots:
void xfailOnWrongRow() const;
void xfailOnAnyRow_data() const;
void xfailOnAnyRow() const;
+ void xfailWithoutVerify_data() const;
+ void xfailWithoutVerify() const;
void xpass() const;
void xpassDataDriven_data() const;
void xpassDataDriven() const;
@@ -168,6 +170,20 @@ void tst_ExpectFail::xfailOnAnyRow() const
QVERIFY(false);
}
+void tst_ExpectFail::xfailWithoutVerify_data() const
+{
+ QTest::addColumn<int>("dummy");
+
+ QTest::newRow("first row") << 0;
+ QTest::newRow("second row") << 1;
+}
+
+void tst_ExpectFail::xfailWithoutVerify() const
+{
+ QVERIFY(true);
+ QEXPECT_FAIL("", "This expected failure should be ignored", Abort);
+}
+
void tst_ExpectFail::xpass() const
{
QEXPECT_FAIL("", "This test should xpass", Abort);