首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用API将测试结果添加到测试运行时未找到测试点错误

使用API将测试结果添加到测试运行时未找到测试点错误
EN

Stack Overflow用户
提问于 2018-07-23 19:24:37
回答 3查看 978关注 0票数 1

将测试结果添加到测试运行时未找到测试点错误

我想使用APi在微软测试管理器/VSTS中更新测试用例的状态。

使用以下接口更新测试结果:

代码语言:javascript
运行
复制
POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}
Content-Type: application/json

JSON

代码语言:javascript
运行
复制
{
  "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} }
    } 
  ]
}

有关详情,请参阅:https://docs.microsoft.com/en-us/vsts/integrate/previous-apis/test/results?view=vsts#add-test-results-to-a-test-run

我创建了示例请求并检查了响应(使用Postman)。

请求:

代码语言:javascript
运行
复制
[
  {
    "testCase": {
      "id": 5000
    },
    "outcome": "Passed"
  }
]

响应:

代码语言:javascript
运行
复制
404 Not Found
"message": "Test point 0 not found.",

然后我在这里读到testPoint = no of configuration。因为我的测试用例有一个配置,Operating system =Windows10;我设置了testPoint = 1。

(使用邮递员)请求:

代码语言:javascript
运行
复制
[
  {
    "testCase": {
      "id": 5000
    },
    "priority": 2,
    "configuration": {
      "id": 14,
      "name": "Windows 10"
    },
    "testPoint": {
      "id": 1
    },
    "outcome": "Passed"
  }
]

响应:

代码语言:javascript
运行
复制
404 Not Found
"message": "Test point 1 not found.",

所以我想知道这个testPoint到底是什么,以及如何在测试用例中找到它?我想从java代码中以编程方式调用此API (用于自动化测试)?有可能吗?

EN

回答 3

Stack Overflow用户

发布于 2018-07-25 19:28:00

您需要直接指定测试点ID,例如:

代码语言:javascript
运行
复制
[
      {
        "testPoint":{
            "id":144
        },
         "priority": 1,
         "outcome": "failed"
      }
   ]

您可以使用REST API获取测试点的id:Get a test result

票数 1
EN

Stack Overflow用户

发布于 2018-07-24 14:50:10

您引用的源是将测试结果添加到测试运行,而不是更新测试运行中的测试结果。你应该参考Update test results for a test run

代码语言:javascript
运行
复制
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的测试结果,并在那里修改值。

代码语言:javascript
运行
复制
https://{account}.visualstudio.com/{teamproject}/_apis/test/runs/{run}/results?api-version=3.0-preview
票数 0
EN

Stack Overflow用户

发布于 2018-07-30 21:32:57

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51477650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档