[Development] [QML] Making tryCompare accept a message
Albert Astals Cid
albert.astals at canonical.com
Wed Jul 31 13:34:46 CEST 2013
Hi, when using the QML TestLib the compare function has a message parameter
\qmlmethod TestCase::compare(actual, expected, message = "")
Fails the current test case if \a actual is not the same as
\a expected, and displays the optional \a message.
We have found the need for tryCompare to have also the message parameter since
at the moment is not there
\qmlmethod TestCase::tryCompare(obj, property, expected, timeout = 5000)
So I was wondering if we should introduce a new function like
\qmlmethod TestCase::tryCompareWithMessage(obj, property, expected,
message = "", timeout = 5000)
or if we could use javascript trickery to just change the existing tryCompare
function to
\qmlmethod TestCase::tryCompare(obj, property, expected, message = "",
timeout = 5000)
and then in the code do (note code is untested but something like that should
be possible)
if (typeof(message) == "number") {
// The 4th parameter used to be timeout
timeout = msg
message = undefined
}
i.e. use Javascript type magic to still let people pass the timeout as fourth
parameter to keep compatibility with the old signature.
Personally i favour this second option but if you prefer the first one that's
fine too.
Cheers,
Albert
More information about the Development
mailing list