selenium - 如何使用 API/端点更新 VSTS/Microsoft 测试管理器中的测试结果
问题描述
如何使用 API 在 VSTS/Microsoft 测试管理器中更新测试结果。如何使用 Selenium/Java 在 VSTS/Microsoft 测试管理器中更新测试结果。
解决方案
通过 API 更新测试结果的程序:
首先使用以下 API 获取测试用例的 testPoints:为此,您需要计划 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}
发送请求并记下 testPoints(作为响应)。
- 然后为此创建一个测试运行。要创建测试运行,您需要计划 id、testPoints 和运行名称。您已经有了计划 ID,您从之前的请求中获得了 testPoints,运行名称可以是任何名称。样品要求:
邮政https://{instance}/DefaultCollection/{project}/_apis/test/runs?api-version={version}
样品主体
{
"name": "Sprint 10 Test Run",
"plan": {
"id": 1234
},
"pointIds": [
10
]
}
发送请求并记下运行 ID(响应)。
- 添加测试结果。为此,您需要测试运行 ID(您从之前的请求中获得)、测试用例 ID 和测试点(您从第一个请求中获得)。
邮政https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}
样品主体
[
{
"state": "Completed",
"testPoint": {
"id": 10
},
"outcome": "Passed",
"testCase": {
"id": 4567
}
}
]
发送请求并记录结果 ID(来自响应)。
- 更新测试运行为此,您需要来自先前请求的结果 id(添加结果)
修补
https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}?api-version={version}
样品主体
[
{
"id": 100000,
"state": "Completed"
}
]
有关详细信息,请参阅:https ://docs.microsoft.com/en-us/vsts/integrate/previous-apis/test/runs?view=vsts#update-test-run
现在检查 VSTS/Test Manager 以获取结果更新。此外,您还可以更新特定配置的结果,只需在添加测试结果的正文中添加配置即可。有关配置详细信息,请参阅:https ://docs.microsoft.com/en-us/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 对象/数组:如何使用字符串创建 JSON 对象?
推荐阅读
- c++ - 访问在 python 中使用 suprocess.check_output 调用的 c++ 代码的输出
- python - 我无法安装opencv
- c# - c#如何使用“实现INotifyPropertyChanged”或“继承DependencyObject”
- java - 预期的数组类型;找到:'java.util.map
' - node.js - 使用 Express.js 和 express-fileupload 上传文件
- python - 将基于 Flask 的 Api(使用女服务员)部署到 Docker
- reactjs - ReactJS 应用程序中奇怪的 cookie 行为
- php - 从数组创建php文件
- algorithm - 在 python 中安装包的精确算法
- angular6 - 如何在我的测试用例中获取非测试组件的实例