Adding Attachments to Automated Test Results with the TRCLI

This tutorial demonstrates how to add attachments to automated test results using the TestRail Command Line Interface (TRCLI). This feature is particularly useful for attaching artifacts like screenshots captured during test execution to provide detailed documentation of failures or results.

The example uses a JUnit and Selenium project with a specification-first approach, where test cases are documented in TestRail before automation. The tutorial explains how to map automated tests to documented test cases using TestRail JUnit extensions. This is achieved by annotating test methods with TestRail case IDs and adding configurations in the pom.xml file.

To attach files, users utilize the TestRail Test Reporter class, setting the TestRail attachment property to the file path of the desired attachment. In the example, a PNG image is added from a sample reports folder.

The process involves running tests using Maven, generating a JUnit-style XML report. The TRCLI is then used to parse this report and upload results to TestRail. The command includes options for configuration, parsing test IDs, and specifying the report location. With the -Y option, the CLI automates the process, making it ideal for CI/CD pipelines.

Once uploaded, results and attachments can be viewed in TestRail under the test run summary.

Attachments like screenshots are accessible within individual test cases, enhancing visibility and documentation.

This method streamlines test management by centralizing automated results and artifacts in TestRail, providing a robust solution for teams seeking seamless integration between automation tools and test management systems.

You are in good company. Many of the world’s best teams use TestRail.