test.attachFile
test.attachFile(pathToFile, message)
This function will copy the file referenced by pathToFile
into the test report directory specified when starting Squish and create an entry in the test report pointing to the file copy if the report generator supports this. The optional message
allows to specify a short description of the attachment and will be included in the report as well.
The pathToFile
can specify the file to attach using an absolute or a relative path. In the case that a relative is being used it'll be appended to the current working directory of the script interpreter running the test.
Currently only the XML3, the HTML and the JSON report generators have dedicated support for attachments. Other generators can be used with test.attachFile, but will only generate a normal log message including the path to the attached file and the provided message
.
The copied file will appear in an attachments subdirectory that is going to be inside a directory named after the testcase. In turn the testcase directory will be inside a directory named after the suite, which is placed in the test report directory. The name of the copied file will match the file name of the originally specified file. If a file of that name already exists in the report directory a number will be added to make the file name unique.
For report generators that do not require specifying a test report directory but rather take a file (like xml2, xml or xmljunit) you can either specify --resultdir
when invoking squishrunner to specify the test report directory or Squish will fall back to generate the attachments directory inside the testcase that is currently being executed when test.attachFile is being invoked.
© 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.