How to Use Test Statements
This section discusses the API Squish offers to perform tests that will create test results. Verification points also use this test API; more coverage of verification points is given in the How to Create and Use Verification Points section. Working with the test result log is discussed in the Processing Test Results section.
To compare two values and write the result of the comparison to the test log, use the Boolean test.compare(value1, value2) function. To simply check that something is true (i.e., to check a Boolean value), use the Boolean test.verify(condition) function. To write some neutral information to the test log at a particular point in the test run, use the test.log(message) function, and to write a warning to the test log use the test.warning(message) function.
Here are a few examples that show how to use these functions.
lineedit = waitForObject(":Address Book - Add.Forename:_QLabel") test.verify(lineedit.enabled) test.compare(lineedit.text, "Jane") test.log("Important note", "This is an important note about the test") test.warning("Suspicious warning", "This test is incomplete and should be extended!")
var lineedit = waitForObject(":Address Book - Add.Forename:_QLabel"); test.verify(lineedit.enabled); test.compare(lineedit.text, "John"); test.log("Important note", "This is an important note about the test"); test.warning("Suspicious warning", "This test is incomplete and should be extended!");
my $lineedit = waitForObject(":Address Book - Add.Forename:_QLabel"); test::verify($lineedit->enabled); test::compare($lineedit->text, "Jane"); test::log("Important note", "This is an important note about the test"); test::warning("Suspicious warning", "This test is incomplete and should be extended!");
lineedit = waitForObject(":Address Book - Add.Forename:_QLabel") Test.verify(lineedit.enabled) Test.compare(lineedit.text, "Jane") Test.log("Important note", "This is an important note about the test") Test.warning("Suspicious warning", "This test is incomplete and should be extended!")
set lineedit [waitForObject ":Address Book - Add.Forename:_QLabel"] test verify [property get $lineedit enabled] test compare [property get $lineedit text] "John" test log "Important note" "This is an important note about the test" test warning "Suspicious warning" \ "This test is incomplete and should be extended!"
Both the test.log(message) and test.warning(message) functions can be given either one or two arguments, the first is the "message" text, and the optional second argument can be used to provide additional details.
Many other test functions are available, including ones for verifying expected failures and expected exceptions, and various functions for writing messages to the test log. The complete API is documented in the Verification Functions section in the Tools Reference.
© 2024 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.