Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to create an empty test execution in jira using REST API and XRay for JIRA

Nidhi Morolia
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 9, 2018

I want to create an empty test execution through REST API, to which I will later import results.

2 answers

0 votes
Timo Vortmeyer November 17, 2020

What was said before is still correct... You can use Jiras API to add a new test execution.

But I have to say it is not that easy. There are several custom fields that are used by Xray and that are needed to be filled. And these are not documented so far.

I found out the structure of the payload after I submitted a GET to an existing Test Execution.

curl -u "<YOUR USER>:<YOUR PW>;" -k -X GET -H "Content-Type: application/json" <YOUR SERVER>/rest/api/2/issue/<YOUR EXISTING TEST EXECUTION>

I used the output as a template. Now I was able add a new Test Execution:

curl -u "<YOUR USER>:<YOUR PW>;" -k -X POST -H "Content-Type: application/json" -d "@c:\temp\example.json" <YOUR SERVER>/rest/api/2/issue

I used this payload (exampel.json):

{
   "fields": {
      "project": {
         "id": "<YOUR PROJECT ID>"
      },
      "summary": "Test Execution summary",
      "description": "Description of the Test Execution",
      "issuetype": {
         "id": "10302"
      },
      "customfield_10627": ["<YOUR KEY TO THE LINKED TEST PLAN>"]
   }
}

 This added an empty Test Execution which is linked to a Test Plan. You have to add the Test Plan to the field "customfield_10627".

But I still don't know if the numeric value of the custom fields are stable in every Jira/Xray installation. Do anybody else know this answer?

Timo Vortmeyer November 17, 2020

I found the solution on my own. The numbers might be dynamic. I used this answer:

https://community.atlassian.com/t5/Jira-Core-questions/Getting-Custom-Field-Label-REST/qaq-p/47427

0 votes
José Domingues _Xray_
Atlassian Partner
May 14, 2018

Hi Didhi,

Did you check Xray documentation on how to create tests and test executions using REST API here:

https://confluence.xpand-addons.com/display/XRAY/Tests+-+REST

https://confluence.xpand-addons.com/display/XRAY/Test+Executions+-+REST

 

Best regards,

Xpand Add-ons Team

Lingxiao Wu July 20, 2020

I believe creating an empty test execution could be done by calling jira api and passing the test execution issue type

Susana Repeto Pastrana
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 13, 2020

Could you at least link the Jira API documentation section where it shows how to create one?

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events