Azure devops rest api,更新测试计划的结果

时间:2021-06-13 17:10:28

标签: rest azure-devops-rest-api

您好,我正在尝试将给定测试计划的结果从 active 更新为 passedfailed,例如使用 azure devops休息api This is the list of test plans 我使用

获得了测试计划的列表
GET https://dev.azure.com/fodservices/Training%20projects/_apis/testplan/Plans/70152/Suites/70154/TestPoint?api-version=6.1-preview.2

4 个结果之一是:

{
    "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": "aprico-tester@outlook.fr",
                "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": "obouattour@freedomofdev.com",
                "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"
            }
        }
]
}

我可以使用 PATCH 将测试计划的结果从活动更改为其他内容吗?什么是 PATCH 请求和我应该发送的正文请求以更改结果

1 个答案:

答案 0 :(得分:0)

当然,您可以使用 API“Test Point - Update”来更新测试点的结果。

例如,我有两个测试点(id 是 2223)是 'Active '。

enter image description here

我可以使用此 API 将一个更新为“Passed”,将另一个更新为“Failed”。

  • 请求 URI:
PATCH https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/{planId}/Suites/{suiteId}/TestPoint?api-version=6.1-preview.2
  • 请求正文:
[
    {
        "id": 22,
        "results": {
            "outcome": "passed"
        }
    },
    {
        "id": 23,
        "results": {
            "outcome": "failed"
        }
    }
]
  • 结果:执行 API 后,刷新页面。

enter image description here

相关问题