Blog / DevOps & Agile


Xray v2.1 – Importing JUnit XML reports

Latest sneak peek about Importing JUnit XML reports

JUnit is used massively in the Java world but not only. In fact, many testing frameworks are using JUnit XML reports as the “de facto standard” report format.

Xray for JIRA now gives you the possibility to import those JUnit test results into JIRA.

You can directly import your JUnit results using the REST API or the Import Execution Results button from the Test Execution screen.

How it works

Lets start looking at JUnit’s XML format.

The simplified tag hierarchy of these type of reports can be represented in the following diagram:

diagram junit

Below is a simplified example of a JUnit XML report, containing a Test Suite with 2 Test Cases (one failing and one passing).

junit report


The Test Cases are imported to Xray’s Generic Test issues, and the “name” and “classname” attributes are concatenated and mapped to the “Generic Test Definition” field of the Generic Test.

If a Test already exists with the same “Generic Test Definition”, then it is not created again, although its execution result will be set in the created/updated Test Execution.


The Test Run status will be set based on each Test Case result.

Test Case Result Statuses

The Test case result may have the following statuses, which will be mapped in Xray as follows:

table1 junit

Test Run Overall Statuses

If a Test has more than one context, then the overall execution status may be calculated as:

table2 junit

Importing JUnit Results

There are two ways of importing results to JIRA:

  • By using the Import Executions Results button on a Test Execution;
  • By using the REST API.

Import JUnit Results using the Import Execution Results button

JUnit Test results can be imported back to JIRA, through the Test Execution view issue screen.

To import JUnit Test results to a Test Execution issue containing automated Tests, the following steps must be taken:

1) Open the Test Execution issue view page;

2) Select More > Import Execution Results;

execution results junit

3) The Import Execution Results dialog will be prompted;

4) Click on the Choose Filebutton to navigate to your local disk and select the XML file with the JUnit execution results for the Test Execution

Import JUnit Results using the REST API

To import JUnit XML reports using the REST API, you must use the following endpoint

  • /rest/raven/1.0/import/execution/junit

Refer to the Request Parameters described on the following table to parameterize your REST call accordingly:

required parameters junit

Required parameters: (projectKey or testExecKey) + file

Examples of usage

  • curl -H “Content-Type: multipart/form-data” -u admin:admin -F “[email protected]” “http://yourserver/rest/raven/1.0/import/execution/junit?projectKey=XTP”
  • curl -H “Content-Type: multipart/form-data” -u admin:admin -F “[email protected]” “http://yourserver/rest/raven/1.0/import/execution/junit?testExecKey=XNP-23”
  • curl -H “Content-Type: multipart/form-data” -u admin:admin -F “file=[email protected]” “http://yourserver/rest/raven/1.0/import/execution/junit?projectKey=XTP&testExecKey=XNP-23”
  • curl -H “Content-Type: multipart/form-data” -u admin:admin -F “[email protected]” “http://yourserver/rest/raven/1.0/import/execution/junit?projectKey=XTP&testPlanKey=XTX-12&revision=v2.1.0&testEnvironments=windows;chrome”


As an example, we’ll be using the Junit XML report file presented in the first section.

Two new tests were created in JIRA, and the Test Execution issue was updated with the association of these tests as well.

example junit

As we have one test failing, we are going to check its Execution Details by accessing the Execution page of that Test Run:

example2 junit

The Results section displays all the relevant information about the execution: The Test Suite context, the error message, the duration and the status of that particular test.

In Sum…

JUnit XML reports can now be interpreted by Xray giving you the possibility to have an overview of all your automated tests. It’s never been so easy to know if all your automated tests are passing or not. You can easily integrate your CI builds to report automated test results using the REST API.

The import of Nunit (v2.6 and v3.0) and Robot XML reports will also be included in this version, meaning that Xray 2.1 is a step ahead in the import of automated test results into JIRA.



    • Hi Krasen,
      We are at the latest QA phase of the release so, Xray’s 2.1 version should be out by the end of next week, until 24th March.
      Please keep an eye in our Blog and Twitter to get all the latest news about our releases.
      Xpand Add-ons team

  • Hi,

    I have integrated jenkin JUnit results to XRAY .
    But is there any automated way by which I can add the description of each test case

    As of now test cases are created by xray but if I want to also add the deacription of each test case ,how can I do it apart from manually going and updating the description of each test case.

    my expectation is to have the test description of each test case that was created automatically.
    Please suggest how can i achieve this more effectively.

    Thanks and Regards,
    Mangala Koaldur

    • Hi Mangala,
      It is possible to set additional information in the newly created Test Executions using the multipart endpoint, however it is not possible to do it for the Test Cases. Please check in our documentation some details about the multipart, here.
      We have also this Improvement reported in our backlog, here.
      Please Vote on it, so we’re able to keep track of your interest and Watch it in order to be notified on any changes over this issue.

      Best regards,
      Xray Team

Leave a reply