如何使用API​​ /端点在VSTS / Microsoft测试管理器中更新测试结果

Ela*_*Ela 1 selenium microsoft-test-manager selenium-webdriver azure-devops

如何使用API​​在VSTS / Microsoft测试管理器中更新测试结果。如何使用Selenium / Java更新VSTS / Microsoft Test Manager中的测试结果。

Ela*_*Ela 5

通过API更新测试结果的过程:

  1. 首先使用以下API获得测试用例的测试点:为此,您需要计划ID,套件ID和测试用例ID。在Web视图中打开套件,在URL中可以找到计划ID和套件ID,测试用例ID是测试用例的ID。

    得到 https://{instance}/DefaultCollection/{project}/_apis/test/plans/{plan}/suites/{suite}/points?api-version={version}&testCaseId={string}

发送请求并记下测试点(作为响应)。

有关详细信息,请参阅:https : //docs.microsoft.com/zh-cn/vsts/integrate/previous-apis/test/points?view=vsts#get-a-test-point

  1. 然后为此创建一个测试运行。要创建测试运行,您需要计划ID,testPoints和运行名称。您已经有计划ID,您从先前的请求中获得了testPoints,运行名称可以是任何东西。样品要求:

开机自检 https://{instance}/DefaultCollection/{project}/_apis/test/runs?api-version={version}

样品体

{
  "name": "Sprint 10 Test Run",
  "plan": {
    "id": 1234
  },
  "pointIds": [
    10
  ]
}
Run Code Online (Sandbox Code Playgroud)

发送请求并记下运行ID(响应)。

有关详细信息,请参阅:https : //docs.microsoft.com/zh-cn/vsts/integrate/previous-apis/test/runs?view=vsts#create-new-test-run

  1. 添加测试结果。为此,您需要测试运行ID(从先前的请求中获得),测试用例ID和测试点(从第一个请求中获得)。

开机自检 https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}

样品体

 [
      {
        "state": "Completed",
        "testPoint": {
          "id": 10
        },
        "outcome": "Passed",
        "testCase": {
          "id": 4567
        }
      }
    ]
Run Code Online (Sandbox Code Playgroud)

发送请求并记录结果ID(来自响应)。

有关详细信息,请参阅:https : //docs.microsoft.com/zh-cn/vsts/integrate/previous-apis/test/results?view=vsts#add-test-results-to-a-test-run

  1. 更新测试运行为此,您需要来自上一个请求的结果ID(添加结果)

补丁

https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}?api-version={version}
Run Code Online (Sandbox Code Playgroud)

样品体

[
  {
    "id": 100000,
    "state": "Completed"
  }
]
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅:https : //docs.microsoft.com/zh-cn/vsts/integrate/previous-apis/test/runs?view=vsts#update-test-run

现在,检查VSTS /测试管理器以获取结果更新。另外,您还可以更新特定配置的结果,只需在添加测试结果的正文中添加配置即可。有关配置的详细信息,请参阅:https : //docs.microsoft.com/zh-cn/vsts/integrate/previous-apis/test/configurations?view=vsts#get-a-list-of-test- configurations

现在要使用Java更新结果,请使用RestAssured发送get,post,patch请求并从响应中检索特定数据。有关放心的详细信息,请参阅:https : //github.com/rest-assured/rest-assured/wiki/Usage

为了发送发布和补丁请求,您可能需要创建json对象/实体,为此使用minidev json库。如何创建JSON对象/数组:如何使用String创建JSON对象?