cancel
Showing results for 
Search instead for 
Did you mean: 

Use API to see if TestRunResult has file(s) attached

SOLVED
New Contributor

Use API to see if TestRunResult has file(s) attached

I am using the REST and SOAP APIs in Java code to fetch data, especially attachments, from QAComplete projects. When checking if an entity has an attachment, in most cases there is this handy json key "nbr_files" attached to the object in the Get reply.

 

However, when I get down to test run results level, this json key is nowhere to be found. Here's an example:

I call Get on:

http://qacomplete.companyUrl/rest-api/service/api/v2/projects/projId/testruns/testrunId/items/itemId...

And get the following json object:

...

"test_run_results": [
{
"id": testRunResultId,
"test_run_item_id": idNo,
"seq": 1,
"is_stopped_on_fail": false,
"status_code": "Passed",
"step": "Test data<br> <br>",
"expected_result": "xxxxx",
"test_step_id": idNo,
"project_id": projId,
"is_tokenized": false
} ]

...

In this test_run_result item, there is no "nbr_files" key, but I have verified that there is actually a file attached to this entity. That is I can run

soap.getAttachmentList(projId, testRunResultId, "TestRunResults");

and get a list of attachments.

 

So finally, my question is, is it possible to see if a testRunResult item has an attachment without having to call SOAP.getAttachmentList() for every item in the test_run_results array?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: Use API to see if TestRunResult has file(s) attached

Hi @krian,

 

Yes, you will need to iterate through items.

 

As for the performance, I made an experiment - sent a similar request to SOAP and to the REST service, here are the results: 

SOAP GET TestRuns_Load - 2916ms

REST GET /api/v2/projects/{ProjectId}/testruns/{Id} - 1665ms

So, the response from the REST service was faster.

 

You can post your ideas here: https://community.smartbear.com/t5/QAComplete-Feature-Requests/idb-p/QAComplete_Feature_Requests


Anastasia
Customer Care Team


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

3 REPLIES 3
Highlighted
Moderator

Re: Use API to see if TestRunResult has file(s) attached

Hi Krian,

 

If you want to use the following methods for the Test Run Results, you should know the "test_run_results/id" value:

GET /api/v1/projects/{ProjectId}/{EntityCode}/{EntityId}/files

POST /api/v1/projects/{ProjectId}/{EntityCode}/{EntityId}/files

GET /api/v1/projects/{ProjectId}/{EntityCode}/{EntityId}/files/{Id}

PUT /api/v1/projects/{ProjectId}/{EntityCode}/{EntityId}/files/{Id}

PATCH /api/v1/projects/{ProjectId}/{EntityCode}/{EntityId}/files/{Id}

DELETE /api/v1/projects/{ProjectId}/{EntityCode}/{EntityId}/files/{Id}

 

So, you will need to do the following:

1. Use the GET /api/v2/projects/{ProjectId}/testruns method to find the needed run
2. To find out the Test Run Result Id, use the following method:

GET /api/v2/projects/{ProjectId}/testruns/{Id}/items/
Please see the example:

3.png

 

P.S.
The attachments for "TestRunResults" are the same files as in the "Actual Result" field for the test steps
5.png


Anastasia
Customer Care Team


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

New Contributor

Re: Use API to see if TestRunResult has file(s) attached

Hello Anastasia and thank you for the reply.

 

Do I understand correctly that the method you suggests involves iterating through each element in the test_run_results array and using the id to check if there is a file attached by using REST rather than SOAP?

 

I wasn't clear enough in my previous question, that my concern is mostly about the performance of the program. As both methods involve iterating through each item in the array and performing a "get list of files" call, is there any difference in performance between using the REST rather than SOAP api's?

 

For future updates, it might be helpful for users if you add nbr_files to each item in the test_run_results array that results from calling "/api/v2/projects/{ProjectId}/testruns/{Id}/items/". Then it would be possible to call any version of "get list of files" only on items that actually contain files, which would be a good performance enhancement.

Moderator

Re: Use API to see if TestRunResult has file(s) attached

Hi @krian,

 

Yes, you will need to iterate through items.

 

As for the performance, I made an experiment - sent a similar request to SOAP and to the REST service, here are the results: 

SOAP GET TestRuns_Load - 2916ms

REST GET /api/v2/projects/{ProjectId}/testruns/{Id} - 1665ms

So, the response from the REST service was faster.

 

You can post your ideas here: https://community.smartbear.com/t5/QAComplete-Feature-Requests/idb-p/QAComplete_Feature_Requests


Anastasia
Customer Care Team


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

New Here?
Join us and watch the welcome video: