将测试结果添加到测试运行中时找不到测试点错误
我想使用APi更新Microsoft Test Manager / VSTS中测试用例的状态。
以下API用于更新测试结果:
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} }
}
]
}
我创建了示例请求并检查了回复(使用邮递员)。
请求:
[
{
"testCase": {
"id": 5000
},
"outcome": "Passed"
}
]
响应:
404 Not Found
"message": "Test point 0 not found.",
然后在这里我读到testPoint =没有配置。 由于我的测试用例具有一种配置,因此操作系统=窗口10;操作系统=窗口10。我将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(用于自动化测试)吗?有可能吗?
答案 0 :(得分:1)
您需要直接指定测试点ID,例如:
[
{
"testPoint":{
"id":144
},
"priority": 1,
"outcome": "failed"
}
]
您可以使用以下REST API获取测试点的ID:Get a test result
答案 1 :(得分:0)
您所指的来源是将测试结果添加到测试运行中,而不是在测试运行中更新测试结果。您应该参考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
答案 2 :(得分:0)
实际上有一个API可以获取testPoint,有关详细信息,请参阅: https://docs.microsoft.com/en-us/vsts/integrate/previous-apis/test/points?view=vsts#get-a-list-of-test-points