test.attachFile

test.attachFile(pathToFile, message)

This function will copy pathToFile into the test report directory, and if supported, create a link from the test report to the copied file. The optional message can be a short description of the attachment and may be included in the report, depending on the report generator used.

The pathToFile can be an absolute or a relative path, relative to the working directory of the script interpreter.

The copied file appears in the report directory under SuiteName/TestName/attachments, with the filename of pathToFile. If a file of that name already exists, a number is appended to make the filename unique.

Currently, only the xml3, html, and junit reports generate links to the attachments. Other generators can be used with test.attachFile, but may only generate a log message instead of a proper link.

For report generators that do not require specifying a test report directory but rather take a file (like xml2, xml or xmljunit) you can specify --resultdir when invoking squishrunner to specify the test report directory. If no result directory is provided, Squish will store attachments under the test case's directory.

© 2025 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.

Search Results