Search code examples
gojunitjirajira-xray

Reference Jira Requirements in Go tests


  • We are using test automation in Go
  • We are using XRay to manage our tests in Jira
  • In our CI/CD pipeline, we are running gotestsum to create JUnit test output in a results.xml file
  • In our CI/CD pipeline we are uploading the results.xml via XRay API
  • https://docs.getxray.app/display/XRAY/v2.0#/Import/post-import-execution
  • Our test results land in Jira and are visible

What I want to do is, somewhere in the test definition in Go, make a reference to a feature requirement and have the test case linked automatically in Jira so that it counts as 'coverage'.

It looks like I should be able to insert the Requirement ID into the JUnit output using a test log formatter, but I am not sure how to transform this into the XRay payload and where it need to go in the XRay payload .

Wondering if anyone else has managed to achieve this?


Solution

  • I'm not familiar with gotestsum but it seems that you will need to contribute to the project in order to be able to add annotations to the JUnit report generated here: https://github.com/gotestyourself/gotestsum/blob/main/internal/junitxml/report.go so that you can specify a Test or Requirement in an annotation that will be added as a property in the JUnit report.

    We already have contributed to some projects to add the possibility to have specific annotations to link requirements to tests, check the below examples: