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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

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

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
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

580 views 5 21
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you