Getting more from TRCLI

Specification-first workflow

Optional Enhancements

Beyond just submitting pass/fail results, you can enrich your test run data in TestRail by including attachments (e.g., screenshots, logs) and comments (e.g., contextual notes or explanations) alongside your test results. These enhancements are especially helpful when reviewing failed or flaky tests and enable both technical and non-technical stakeholders to better understand what happened.

If you are using JUnit framework , you can annotate the automated test cases using the TestRail annotation feature provided by the testrail-junit-extensions.

Attachments: Include Screenshots or Logs

You can automatically upload files, such as screenshots or logs, as part of a test result by using the testrail_attachment_1 property in your test code.

When to use it:

  • Capture screenshots on test failure
  • Attach log files for detailed diagnostics
  • Add debug outputs or system states

JUnit + Java example:

// Java test method using TestRail extensions
@ExtendWith(TestRailTestReporterParameterResolver.class)
class HomePageTest {
  @Test
  @TestRail(id = "C110")
  void testDemoLinkVisible(TestRailTestReporter customReporter) {
    assertTrue(driver.findElement(By.linkText("Get a Demo")).isDisplayed());
    customReporter.setProperty("testrail_attachment_1", "screenshots/failure_C110.png");
  }
}
  • testrail_attachment_1 references the local path to the file you want to upload.
  • You can include up to 10 attachments using testrail_attachment_1 through testrail_attachment_10.

When the test results are uploaded using the CLI, these files will be visible within the result view for the corresponding case in TestRail.

Comments: Add Context to Test Outcomes

Use the testrail_result_comment property to add a descriptive message to any test result.

When to use it:

  • Clarify an unexpected or intermittent failure
  • Annotate skipped tests or environment-specific behavior
  • Provide insight into assertion logic or results

JUnit + Java example:

@ExtendWith(TestRailTestReporterParameterResolver.class)
class HomePageTest {
  @Test
  @TestRail(id = "C109")
  void testHomePageTitle(TestRailTestReporter customReporter) {
    assertTrue(driver.getTitle().contains("TestRail"));
    customReporter.setProperty("testrail_result_comment", "Title check passed. Tested in staging environment.");
  }
}

Once uploaded, this comment will appear alongside the result for that test case in the TestRail UI, making it easier for others to understand the status without digging through logs or code.

Specification first workflow ss8.JPG

These enhancements help make your automated test results more human-readable, actionable, and review-friendly - especially useful in team environments where results are interpreted by testers, leads, or managers.

 


Was this article helpful?
0 out of 0 found this helpful