Reputation: 368
I'm using Azure DevOps Services REST API 5.1 to create test runs in my DevOps Test Plan.
I first create a test run like the documents here
Postman request:
POST /{Organization}/{project}/_apis/test/runs?api-version=5.0 HTTP/1.1 Host: dev.azure.com
Authorization: Basic xyz
Content-Type: application/json
{
"name": "koko",
"automated": true
}
I then add a test result to the previously created test Run. doc.
Postman Request:
POST /{organization}/{project}/_apis/test/Runs/240/results?api-version=5.0 HTTP/1.1
Host: dev.azure.com
Authorization: Basic xyz
Content-Type: application/json
[
{
"Project": {
"Id": "xxxxxxxx-xxxx-xxxx-xxxx-c748b3ba25f6",
"Name": "Project",
"Url": "https://dev.azure.com/xx/_apis/projects/xxxxxxxx-xxxx-xxxx-xxxx-c748b3ba25f6"
},
"StartedDate": "2020-07-07T16:25:56.4171217+03:00",
"DurationInMs": 550,
"Outcome": "Passed",
"State": "Completed",
"TestCase": {
"Id": "6304",
"Name": "TestCase",
"Url": "https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/6302/Suites/6303/TestCase/6304"
},
"TestRun": {
"Id": "240",
"Name": "koko",
"Url": "https://dev.azure.com/{organization}/{project}/_apis/test/Runs/240"
},
"Priority": 2,
"CreatedDate": "2020-07-07T16:24:56.4171092+03:00",
"TestCaseTitle": "TEST8",
"TestPlan": {
"Id": "6302",
"Name": "Template",
"Url": "https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/6302"
},
"TestSuite": {
"Id": "6303",
"Name": "Template",
"Url": "https://dev.azure.com/{organization}/{project}/testplan/Plans/6302/Suites/6303"
},
"AutomatedTestName": "TEST8"
}
]
The problem I'm facing is that the created test result does not show the referenced Test Plan, Test Case Id, and Test Suite.
Current Result:
Expected Result:
Upvotes: 4
Views: 1769
Reputation: 16133
Additionally, you need Test points of your test case and work item info (revision)
Here is an example:
Create a test run with planned test points:
https://dev.azure.com/{org}/{teamproject}/_apis/test/runs?api-version=5.1
{
"name": "NewTestRun",
"automated": true,
"plan": {
"id": "103"
},
"pointIds": [3]
}
Add test result:
https://dev.azure.com/{org}/{teamproject}/_apis/test/Runs/{RunId}/results?api-version=5.1
[
{
"Priority": 2,
"State": "Completed",
"outcome": "Passed",
"testCaseRevision": 3,
"testCaseTitle": "Test 1",
"testCase":
{
"id": "106"
},
"testPoint":
{
"id": "3"
},
"AutomatedTestName": "TEST8"
}
]
Upvotes: 2