How to update test case/ test step result for a Test Run using Open API?

Considering a scenario, When executing a Test Run manually, there is an option to pass/fail/block etc to each test case and test step. How can these test case/step results be updated using the Open API? Here's how you do it.

Steps for getting testResultId of test case:

For updating the test case result, requires testResultId. We need to run below API:

Expand Test Case execution details
Post /testrun/testexecution/:testRunIssueId


Description

POST Test Cases/Scenarios and Stories linked with the given test run along with their summary and status. 


Example 

  1. Get testRunIssueId from test run.



  2. Execute the API mentioned above by specifying the value for testRunIssueId and use the following body parameters.


   

     Body:

     

Body
{"projectId":"10001",
"offset":0,
"automationRun":true,
"whereClause":[],
"assignedToUsers":[],
"executionResult":[],
"testScenarioWithDefectRequired":false
}

See the output :

Steps for getting testResultId of test steps:

We can get the testResultId of the test steps, if you want to update the execution result of the test steps. We need to run below API.

POST Expand Test Step execution details
Post /testrun/testexecution/:testRunIssueId/:testResultId

Description

POST  Test Steps which are linked with Test Case.


Example 

  1. Need to specify testRunIssueIdtestCaseIssueId for making an API call. Refer an attachment.



  2. See the output:


Steps for updating execution result for test case & test steps:

Now we have testResultId for both test case and test steps, need to proceed with updating test case/ test steps execution result. As indicated in very first attachment - test case and all associated test steps are marked as NOT EXECUTED Let's update test case as PASS and associated test steps as BLOCKED & FAIL using below API.

Update comment, execution result or actual result
PUT /testrun/{testRunIssueId}/update

Description

You can update either comment, actual result, execution result or all of them together. Here you can directly pass test result id or multiple issue ids. Here is the help document for this API in detail.


Example

  1. Specify testRunIssueId in Parameters and JSON inside Body part. We need to add the "result" and "testResultId" attributes in the API in order to update the execution status of the test case & test steps. Refer to attachments.







  2. See the final Output with updated execution results.


Note: In order to automatically propagate Test Step execution result to Test Case, enable 'Automatically propagate Test Step execution result to Test Case' under Execution Preferences in QMetry Configuration.