diff options
author | Albert Astals Cid <albert.astals@canonical.com> | 2017-04-04 16:26:20 +0200 |
---|---|---|
committer | Albert Astals Cid <albert.astals@canonical.com> | 2017-04-05 07:07:19 +0000 |
commit | af72231fe4a91226d945db9a526fb755332548eb (patch) | |
tree | 4739e114b5aa6c2557444cb91c84fbf738a949be | |
parent | fdb822613989c5975ba282b775e6d194467bdef4 (diff) |
Error out if TestCase.verify receives more than 2 parameters
Change-Id: I3299f602970067aaef290d4f1c7449d3ab03fb3c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/imports/testlib/TestCase.qml | 3 | ||||
-rw-r--r-- | tests/auto/qmltest/selftests/tst_selftests.qml | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 3e6eb64311..8c1744a2b2 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -444,6 +444,9 @@ Item { or \c{QVERIFY2(condition, message)} in C++. */ function verify(cond, msg) { + if (arguments.length > 2) + qtest_fail("More than two arguments given to verify(). Did you mean tryVerify() or tryCompare()?", 1) + if (msg === undefined) msg = ""; if (!qtest_results.verify(cond, msg, util.callerFile(), util.callerLine())) diff --git a/tests/auto/qmltest/selftests/tst_selftests.qml b/tests/auto/qmltest/selftests/tst_selftests.qml index 439ea7a70d..5555876014 100644 --- a/tests/auto/qmltest/selftests/tst_selftests.qml +++ b/tests/auto/qmltest/selftests/tst_selftests.qml @@ -167,6 +167,16 @@ TestCase { caught = true } verify(caught) + + caught = false; + try { + testCase.verify(true, "foo", "bar") + } catch (e) { + compare(e.message, "QtQuickTest::fail") + compare(functions.failmsg, "More than two arguments given to verify(). Did you mean tryVerify() or tryCompare()?") + caught = true + } + verify(caught) } function test_compare() { |