summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-12-16 09:26:02 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-12-16 09:26:02 +1000
commit8bbdf2bb1f81f5a655e44d1eec14f4170e00a1df (patch)
tree5ce1dcaf7bb96a934dcba852ce30c534879d0ade
parent81e09bb0d7bb5b8ce58773f5e9422b3c507006dd (diff)
Fix expectFail() example and clarify documentation
-rw-r--r--src/imports/testlib/TestCase.qml16
-rw-r--r--src/imports/testlib/testcase.qdoc20
-rw-r--r--tests/qmlexample/tst_basic.qml2
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)
}