Squish tip of the week: How to group test results into sections

Squish tip of the week: How to group test results into sections

Sometimes it can be useful to group comparison results or error logs into specific sections. This simplifies the handling of the evaluation and gives an illustrated insight into the data.

Squish will thereby show results nested and if wanted over several levels. If test run from command-line the log messages are added to the test when a section begins or ends – unless the XML3 report generator is used.

Please note that test.startSection should always be closed with test.endSection to prevent erroneous test reports.

Snippet

Grouping test results into logical units
test.startSection(title);

or

test.startSection(title, description);

and

test.endSection();

Example:

def main():
    startApplication("Addressbook")
    clickButton(waitForObject(":New_Button"))
    clickButton(waitForObject(":Add_Button"))
    test.startSection("Form , Surname & Name")
    type(waitForObject(":_Edit"), "Peter")
    test.log("Peter")
    type(waitForObject(":_Edit_2"), "Lustig")
    test.log("Lustig")
    test.endSection()
    test.startSection("Form , E-Mail & Telefon")
    type(waitForObject(":_Edit_3"), "peter@lustig.de")
    test.log("peter@lustig.de")
    type(waitForObject(":_Edit_4"), "123")
    test.log("123")
    test.endSection()
    clickButton(waitForObject(":Address Book - Add.OK_Button"))
    mouseClick(waitForObject(":File_MenuItem_2"))
    mouseClick(waitForObject(":_Menu"), 91, 110, MouseButton.PrimaryButton)
    mouseClick(waitForObject(":Address Book.No_Button"), 49, 5, MouseButton.PrimaryButton)

Example test results after running the test case

Test results with test.startSection and test.endSection


Note

To avoid misleading test reports always call test.endSection after calling test.startSection!

As calls can also be nested, i.e. multiple subsequent calls to startSection it is required that endSection gets called multiple times as well.


Are you using this function in Squish? Please let us know in the comments below.


Related topics