Updating the results of a test run of a test case
Finding the test runs generated for a test case
For first we need to consider that if you generate a test run for a test case, two test runs will be created: one visible and one hidden to store the results.
To update the results we need to find the hidden item, which can be done with the following endpoint using a cbQL query:
Request:
POST /v2/item
Request body:
{
"page": 1,
"pageSize": 25,
"queryString": "referenceToId ={testCaseItemId} AND description LIKE '%TEST_CASE_INDEX%'"
}
Response:
{
"page": 1,
"pageSize": 25,
"total": 1,
"items": [
{
"id": 1142,
"uri": "/item/1142",
"name": "Run of My first Test Case",
"type": "TrackerItem",
"parent": {
"id": 1141,
"uri": "/item/1141",
"name": "Quick Test Run for My first Test Case at Aug 22 2019",
"type": "TrackerItemReferenceField"
},
"version": 1,
"description": "//TEST_CASE_INDEX:0",
"descriptionFormat": "Wiki",
...
"customFields": [
{
"fieldId": 10000,
"uri": "/tracker/6606/field/10000",
"name": "Sequential",
"type": "BoolCustomFieldReference",
"value": false
},
{
"fieldId": 1000000,
"uri": "/tracker/6606/field/1000000",
"name": "Test Cases",
"type": "TableCustomFieldReference",
"values": [
[
{
"fieldId": 1000001,
"uri": "/tracker/6606/field/1000001",
"name": "Test Case",
"type": "ChoiceCustomFieldReference",
"values": [
{
"id": 1135,
"uri": "/item/1135",
"name": "My first Test Case",
"type": "TrackerItemReference"
}
]
}
]
]
},
{
"fieldId": 10002,
"uri": "/tracker/6606/field/10002",
"name": "Run only Accepted TestCases",
"type": "BoolCustomFieldReference",
"value": false
},
{
"fieldId": 2000000,
"uri": "/tracker/6606/field/2000000",
"name": "Test Step Results",
"type": "TableCustomFieldReference",
"values": [
[
{
"fieldId": 2000001,
"uri": "/tracker/6606/field/2000001",
"name": "Action",
"type": "WikiTextCustomFieldReference",
"value": "First action"
},
{
"fieldId": 2000002,
"uri": "/tracker/6606/field/2000002",
"name": "Expected result",
"type": "WikiTextCustomFieldReference",
"value": "First expected result"
},
{
"fieldId": 2000003,
"uri": "/tracker/6606/field/2000003",
"name": "Critical",
"type": "BoolCustomFieldReference",
"value": false
}
],
[
{
"fieldId": 2000001,
"uri": "/tracker/6606/field/2000001",
"name": "Action",
"type": "WikiTextCustomFieldReference",
"value": "Second action"
},
{
"fieldId": 2000002,
"uri": "/tracker/6606/field/2000002",
"name": "Expected result",
"type": "WikiTextCustomFieldReference",
"value": "Second expected result"
},
{
"fieldId": 2000003,
"uri": "/tracker/6606/field/2000003",
"name": "Critical",
"type": "BoolCustomFieldReference",
"value": false
}
]
]
}
],
...
}
]
}
Update the test step results
Once you've found the item, you can update the table field, which contains the actual results, and also update the status of the test run.
Request:
PUT /v2/item/{hiddenTestRunId}/field
Request body:
{
"fieldValues": [
{
"fieldId": 7, // Updating the status
"type": "SingleOptionChoiceFieldValue",
"value": 4 // to Finished
}
],
"tableValues": [
{
"fieldId": 2000000, // Table field containing the actual results
"type": "TrackerItemTableFieldValue",
"rows": [
{
"fieldValues": [
{
"fieldId": 2000001, // Action of the test step
"type": "WikiTextFieldValue",
"value": "Brake with semi-metallic brake pads"
},
{
"fieldId": 2000002, // Expected result of the test step
"type": "WikiTextFieldValue",
"value": "The car brake pads work fine and the car stops"
},
{
"fieldId": 2000003, // Criticality of the test step
"type": "BoolFieldValue",
"value": false
},
{
"fieldId": 2000004, // Actual result of the test step
"type": "WikiTextFieldValue",
"value": "The car brake pads work fine and the car stops"
},
{
"fieldId": 2000005, // Result of the test step
"type": "TextFieldValue",
"value": "PASSED"
}
]
},
{
"fieldValues": [
{
"fieldId": 2000001,
"type": "WikiTextFieldValue",
"value": "1"
},
{
"fieldId": 2000002,
"type": "WikiTextFieldValue",
"value": "1"
},
{
"fieldId": 2000003,
"type": "BoolFieldValue",
"value": false
},
{
"fieldId": 2000004,
"type": "WikiTextFieldValue",
"value": "1"
},
{
"fieldId": 2000005,
"type": "TextFieldValue",
"value": "PASSED"
}
]
}
]
}
]
}
Please note: Here we need to provide all the information we already have for the test steps because table fields are considered as one value. If you only provide the fields which you want to be changed that would mean that you want to delete the rest.