Squish Tip: Using startSection/endSection to improve test result readability

Squish 6 introduces a new feature for helping to document parts of a test case.

test.startSection(title, description) can be used to describe the start of something. The description is optional and also shows up in the test results file.

test.endSection() is used to describe its end point.

Sections are especially useful for marking groups of related results in data-driven testing, and also for describing a hierarchy of test results, where simple log messages will not suffice.

As an example, in the Qt AddressBook’s tst_adding_data.py test script, we added start and end sections around the processing of each row of test data.

        test.startSection (" Testing {0} {1}".format(forename, surname), email)
        addNameAndAddress((forename, surname, email, phone))
        checkNameAndAddress(table, record)

This introduces a level of hierarchy in the XML <test> results, so when tests are run from the SquishIDE, we can see sections as tree nodes in the Test Results window:

Sections as tree nodes in test results

Sections as tree nodes in test results

From the HTML test results, we also see expandable and collapsible tree nodes for each test section:

Sections rendered as tree nodes in the HTML test results.

Sections rendered as tree nodes in the HTML test results.

Trainer and Consultant for Froglogic and Qt.
Co-author of “Introduction to Design Patterns in C++ and Qt”


Leave a reply

Your email address will not be published. Required fields are marked *