0
votes

Hello I'm trying to update the outcome of a given test plan from active to passed or failed for example using the azure devops rest api This is the list of test plans I got the list of the test plans using

GET https://dev.azure.com/fodservices/Training%20projects/_apis/testplan/Plans/70152/Suites/70154/TestPoint?api-version=6.1-preview.2

And one of the 4 results is :

{
    "value": [
        {
            "id": 11431,
            "tester": {
                "displayName": "Test Aprico",
                "url": "https://spsprodweu2.vssps.visualstudio.com/A3e01c801-26e0-432b-a5f3-151daaac66b1/_apis/Identities/f908e913-62c6-46c0-b5d0-a1bf5b0ec545",
                "_links": {
                    "avatar": {
                        "href": "https://dev.azure.com/fodservices/_apis/GraphProfile/MemberAvatars/msa.YWNmM2E4ZTgtMWRlYy03MzVkLWFiNjYtNWJiMWIzNWFhZWRh"
                    }
                },
                "id": "f908e913-62c6-46c0-b5d0-a1bf5b0ec545",
                "uniqueName": "[email protected]",
                "imageUrl": "https://dev.azure.com/fodservices/_apis/GraphProfile/MemberAvatars/msa.YWNmM2E4ZTgtMWRlYy03MzVkLWFiNjYtNWJiMWIzNWFhZWRh",
                "descriptor": "msa.YWNmM2E4ZTgtMWRlYy03MzVkLWFiNjYtNWJiMWIzNWFhZWRh"
            },
            "configuration": {
                "id": 58,
                "name": "Windows 10"
            },
            "isAutomated": false,
            "project": {
                "id": "45f6aa02-cc12-465a-8f0b-96ec1c41f029",
                "name": "Training projects",
                "state": "unchanged",
                "visibility": "unchanged",
                "lastUpdateTime": "0001-01-01T00:00:00"
            },
            "testPlan": {
                "id": 70152,
                "name": "Automated tests"
            },
            "testSuite": {
                "id": 70154,
                "name": "Mr Robot"
            },
            "lastUpdatedBy": {
                "displayName": "Omar BOUATTOUR",
                "url": "https://spsprodweu2.vssps.visualstudio.com/A3e01c801-26e0-432b-a5f3-151daaac66b1/_apis/Identities/14aaca6f-a5d3-4392-86bb-64e1a1e7fa28",
                "_links": {
                    "avatar": {
                        "href": "https://dev.azure.com/fodservices/_apis/GraphProfile/MemberAvatars/aad.ZTAzMTcwOWEtYmMzNC03MzY1LTk4ODYtZGJkMjRhMDliNWY3"
                    }
                },
                "id": "14aaca6f-a5d3-4392-86bb-64e1a1e7fa28",
                "uniqueName": "[email protected]",
                "imageUrl": "https://dev.azure.com/fodservices/_apis/GraphProfile/MemberAvatars/aad.ZTAzMTcwOWEtYmMzNC03MzY1LTk4ODYtZGJkMjRhMDliNWY3",
                "descriptor": "aad.ZTAzMTcwOWEtYmMzNC03MzY1LTk4ODYtZGJkMjRhMDliNWY3"
            },
            "lastUpdatedDate": "2021-06-13T12:48:17.707Z",
            "results": {
                "lastResultDetails": {
                    "duration": 0,
                    "dateCompleted": "0001-01-01T00:00:00",
                    "runBy": {
                        "displayName": null,
                        "id": "00000000-0000-0000-0000-000000000000"
                    }
                },
                "state": "ready",
                "outcome": "unspecified"
            },
            "lastResetToActive": "2021-06-13T12:48:17.707Z",
            "isActive": true,
            "links": {
                "_self": {
                    "href": "https://dev.azure.com/fodservices/Training%20projects/_apis/testplan/Plans/70152/Suites/70154/TestPoint/11431"
                },
                "sourcePlan": {
                    "href": "https://dev.azure.com/fodservices/Training%20projects/_apis/testplan/Plans/70152"
                },
                "sourceSuite": {
                    "href": "https://dev.azure.com/fodservices/Training%20projects/_apis/testplan/Plans/70152/Suites/70154"
                },
                "sourceProject": {
                    "href": "https://dev.azure.com/fodservices/_apis/projects/Training%20projects"
                },
                "testCases": {
                    "href": "https://dev.azure.com/fodservices/Training%20projects/_apis/testplan/Plans/70152/Suites/70154/TestCase"
                }
            },
            "testCaseReference": {
                "id": 70155,
                "name": "CheckMenuAdmin",
                "state": "Design"
            }
        }
]
}

Can I change the outcome of a test plan from active to something else using PATCH ? and what is the PATCH request and the body request i should send to change the outcome

1

1 Answers

0
votes

Sure, you can use the API "Test Point - Update" to update the outcome of test points.

For example, I have two test points (id are 22 and 23) are 'Active'.

enter image description here

I can use this API to update one to be 'Passed' and another one to be 'Failed'.

  • Request URI:
PATCH https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/{planId}/Suites/{suiteId}/TestPoint?api-version=6.1-preview.2
  • Request Body:
[
    {
        "id": 22,
        "results": {
            "outcome": "passed"
        }
    },
    {
        "id": 23,
        "results": {
            "outcome": "failed"
        }
    }
]
  • Result: after executing the API, refresh the page.

enter image description here