how to update xray test execution tests status with server API?

Demiank100 August 27, 2020

i created a test execution,  inside of it i place 2 tests, i will be getting a file that i need to parse and update the tests status inside that test execution using the API server version.

 

https://docs.getxray.app/display/XRAY/v2.0#/

thanks guys =)

 

 

2 answers

0 votes
Demiank100 August 28, 2020

found to first call:

GET https://MY_SITE/rest/raven/1.0/api/testexec/{TEST_EXECUTION_ISSUE}/test

so i can get the jira issues and their run IDS,  and issue key, 

now that i know them

for each :

PUT https://jiratest.dolgen.net/rest/raven/1.0/api/testrun/{TEST_RUN_ID}/status?status=PASS

 

 

example in python just in case some one needs a hint:

# THIS ONE RETURN ALL THE TEST RUN INSIDE THE TEST EXECUTION ISSUE
response = requests.get('https://{0}/rest/raven/1.0/api/testexec/{1}/test'.format(MY_SITE, TEST_EXECUTION_ISSUE_KEY), auth=(user, password))
print(response.json())
run_tests = response.json()

for i in run_tests:
update_url = "https://{0}/rest/raven/1.0/api/testrun/{0}/status?status=FAIL".format(MY_SITE, i["id"])
response = requests.put(update_url, auth=(user, password))
print(response.text)

 

but there is bug,  if you change the status from current status to the same, will response a 401 authorization error, 

example,  if you change PASS to PASS,    and is not true that you got an authorization issue,  I thought I wasn't using the right user and password, 

if you change to PASS to Fail (or any other status that is not the current one) will give you the responds 200   

 

PASS to PASS:

401

PASS to other Status:

200

Sergio Freire - Xblend
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2020

Hi @Demiank100 ,

nevertheless, I recommend that you use just one HTTP call using the Xray JSON format as it is more efficient; this if you don't  mind updating the results in the end... otherwise, if you want to update the test results in real-time, then you have to go with that solution you mentioned.

https://docs.getxray.app/display/XRAY/Import+Execution+Results+-+REST#ImportExecutionResultsREST-XrayJSONresults

curl -H "Content-Type: application/json" -X POST -u admin:admin --data @data.json http://yourserver/rest/raven/1.0/import/execution



{
"testExecutionKey": "DEMO-1206",
"info" : {
"summary" : "Execution of automated tests for release v1.3",
"description" : "This execution is automatically created when importing execution results from an external source",
"user" : "admin",
"startDate" : "2014-08-30T11:47:35+01:00",
"finishDate" : "2014-08-30T11:53:00+01:00",
},
"tests" : [
{
"testKey" : "DEMO-6",
"start" : "2014-08-30T11:47:35+01:00",
"finish" : "2014-08-30T11:50:56+01:00",
"comment" : "Successful execution",
"status" : "PASS"
}
]
}

 

Note: you can reach out to Xray Support team in case you think you found a bug, or in general, in case you need further assistance.

 

Regards

Sergio

Abhishek Surpur
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!
February 22, 2024

Hi @Demiank100 

 

So, once you find the list of all the test ids which are part of test execution, you'll update result one by one by passing test id in API call.

 

Now my question is, 

Say if a testID is part of multiple test executions, where will test result get updated?

 

For example test-1234 is part of testexec-123 and testexec-456. Now if I update result of test-1234 by calling :

PUT https://jiratest.dolgen.net/rest/raven/1.0/api/testrun/test-1234/status?status=PASS: 

 Which test execution gets updated testexec-123 or testexec-456 ?

0 votes
Sergio Freire - Xblend
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2020

Hi @Demiank100 ,

assuming that you have already some existing Tests in Xray that you want to report the results to, you can do it in several ways:

  1. create a Xray JSON request using one unique call to the respective REST API endpoint; this is the most simple one
  2. you could do a request to the REST API to obtain the Test Run ids and then update one by one using a specific call to update each Test Run's status ; this would lead to many HTTP requests though

In case you aim just to import results from supported automation frameworks, you just need to import the respective report using the respective endpoints.

Note: we have an open-source project that contains Xray-relatated Postman collections, in case you want to see some concrete API usage examples.

 

Regards

Sergio

 

=======================================

A personal blog on testing, Agile, and software development: https://sergiofreire.com

Follow me on Twitter: https://twitter.com/darktelecom

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events