将测试结果添加到测试运行时未找到测试点错误
我想使用APi在微软测试管理器/VSTS中更新测试用例的状态。
使用以下接口更新测试结果:
POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}
Content-Type: application/json
JSON
{
"testCaseTitle": { string },
"testCase": {
"id": { int }
},
"configuration": {
"id": { int },
"name": {string }
},
"testPoint": {
"id": { int }
},
"state": {
enum { Pending, Queued, InProgress, Paused, Completed }
},
"computerName": { string },
"resolutionState": { string },
"priority": { int },
"failureType": { string },
"automatedTestName": { string },
"automatedTestStorage": { string },
"automatedTestType": { string },
"automatedTestId": { string },
"area": {
"name": {string}
},
"owner": {
"DisplayName": {string}
},
"runBy": {
"DisplayName": {string}
},
"outcome": {
enum { None, Passed, Failed, Inconclusive, Timeout, Aborted, Blocked, NotExecuted, Warning, Error, NotApplicable, Paused, InProgress}
},
"errorMessage": { string },
"comment": { string },
"startedDate": { DateTime },
"completedDate": { DateTime },
"durationInMs": { long },
"associatedBugs": [
{
{ "id" : {int} }
}
]
}
我创建了示例请求并检查了响应(使用Postman)。
请求:
[
{
"testCase": {
"id": 5000
},
"outcome": "Passed"
}
]
响应:
404 Not Found
"message": "Test point 0 not found.",
然后我在这里读到testPoint = no of configuration。因为我的测试用例有一个配置,Operating system =Windows10;我设置了testPoint = 1。
(使用邮递员)请求:
[
{
"testCase": {
"id": 5000
},
"priority": 2,
"configuration": {
"id": 14,
"name": "Windows 10"
},
"testPoint": {
"id": 1
},
"outcome": "Passed"
}
]
响应:
404 Not Found
"message": "Test point 1 not found.",
所以我想知道这个testPoint到底是什么,以及如何在测试用例中找到它?我想从java代码中以编程方式调用此API (用于自动化测试)?有可能吗?
发布于 2018-07-25 19:28:00
您需要直接指定测试点ID,例如:
[
{
"testPoint":{
"id":144
},
"priority": 1,
"outcome": "failed"
}
]
您可以使用REST API获取测试点的id:Get a test result
发布于 2018-07-24 14:50:10
您引用的源是将测试结果添加到测试运行,而不是更新测试运行中的测试结果。你应该参考Update test results for a test run
PATCH https://{account}.visualstudio.com/{teamproject}/_apis/test/runs/{run}/results?api-version=3.0-preview
Content-Type: application/json
[
{
"id": { int },
"state": {
enum { Pending, Queued, InProgress, Paused, Completed }
},
"computerName": { string },
"resolutionState": { string },
"priority": { int },
"failureType": { string },
"owner": {
"DisplayName": {string}
},
"runBy": {
"DisplayName": {string}
},
"outcome": {
enum { None, Passed, Failed, Inconclusive, Timeout, Aborted, Blocked, NotExecuted, Warning, Error, NotApplicable, Paused, InProgress}
},
"errorMessage": { string },
"comment": { string },
"startedDate": { DateTime },
"completedDate": { DateTime },
"durationInMs": { long },
"associatedBugs": [
{
{ "id" : {int} }
}
]
}
]
您可以首先get the list of the test results for a test run,然后捕获您想要更新到update API的测试结果,并在那里修改值。
https://{account}.visualstudio.com/{teamproject}/_apis/test/runs/{run}/results?api-version=3.0-preview
发布于 2018-07-30 21:32:57
获取testPoints的接口其实是有的,具体可以参考:https://docs.microsoft.com/en-us/vsts/integrate/previous-apis/test/points?view=vsts#get-a-list-of-test-points
https://stackoverflow.com/questions/51477650
复制相似问题