From 8bbdf2bb1f81f5a655e44d1eec14f4170e00a1df Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 16 Dec 2010 09:26:02 +1000 Subject: Fix expectFail() example and clarify documentation --- src/imports/testlib/TestCase.qml | 16 ++++++++++++---- src/imports/testlib/testcase.qdoc | 20 +++++++++++++------- tests/qmlexample/tst_basic.qml | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 0212c83..ea9df59 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -174,19 +174,27 @@ Item { } function expectFail(tag, msg) { - if (tag === undefined) + if (tag === undefined) { + warn("tag argument missing from expectFail()") tag = "" - if (msg === undefined) + } + if (msg === undefined) { + warn("message argument missing from expectFail()") msg = "" + } if (!qtest_results.expectFail(tag, msg, Qt.qtest_caller_file(), Qt.qtest_caller_line())) throw new Error("QtQuickTest::expectFail") } function expectFailContinue(tag, msg) { - if (tag === undefined) + if (tag === undefined) { + warn("tag argument missing from expectFailContinue()") tag = "" - if (msg === undefined) + } + if (msg === undefined) { + warn("message argument missing from expectFailContinue()") msg = "" + } if (!qtest_results.expectFailContinue(tag, msg, Qt.qtest_caller_file(), Qt.qtest_caller_line())) throw new Error("QtQuickTest::expectFail") } diff --git a/src/imports/testlib/testcase.qdoc b/src/imports/testlib/testcase.qdoc index 4e95c5e..77ddcb6 100644 --- a/src/imports/testlib/testcase.qdoc +++ b/src/imports/testlib/testcase.qdoc @@ -378,24 +378,30 @@ */ /*! - \qmlmethod TestCase::expectFail(tag, message = "") + \qmlmethod TestCase::expectFail(tag, message) In a data-driven test, marks the row associated with \a tag as - expected to fail. When the fail occurs, display the optional - \a message, abort the test, and mark the test as passing. - Similar to \c{QEXPECT_FAIL(tag, message, Abort)} in C++. + expected to fail. When the fail occurs, display the \a message, + abort the test, and mark the test as passing. Similar to + \c{QEXPECT_FAIL(tag, message, Abort)} in C++. + + If the test is not data-driven, then \a tag must be set to + the empty string. \sa expectFailContinue() */ /*! - \qmlmethod TestCase::expectFailContinue(tag, message = "") + \qmlmethod TestCase::expectFailContinue(tag, message) In a data-driven test, marks the row associated with \a tag as - expected to fail. When the fail occurs, display the optional - \a message, and then continue the test. Similar to + expected to fail. When the fail occurs, display the \a message, + and then continue the test. Similar to \c{QEXPECT_FAIL(tag, message, Continue)} in C++. + If the test is not data-driven, then \a tag must be set to + the empty string. + \sa expectFail() */ diff --git a/tests/qmlexample/tst_basic.qml b/tests/qmlexample/tst_basic.qml index d905d9b..07d5a9d 100644 --- a/tests/qmlexample/tst_basic.qml +++ b/tests/qmlexample/tst_basic.qml @@ -58,7 +58,7 @@ TestCase { } function test_expecting() { - expectFail("this is the fail we wanted") + expectFail("", "this is the fail we wanted") verify(false) } -- cgit v1.2.3