【问题标题】:Test point not found error while adding test results to a test run using API使用 API 将测试结果添加到测试运行时未找到测试点错误
【发布时间】:2018-12-30 20:07:03
【问题描述】:

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

我想使用 APi 在 Microsoft 测试管理器/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} }
    } 
  ]
}

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

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

请求:

[
  {
    "testCase": {
      "id": 5000
    },
    "outcome": "Passed"
  }
]

回复:

404 Not Found
"message": "Test point 0 not found.",

然后我在这里读到 testPoint = no of configurations。 由于我的测试用例有一种配置,操作系统 = Window 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(用于自动化测试)?有可能吗?

【问题讨论】:

    标签: azure-devops microsoft-test-manager


    【解决方案1】:

    您指的来源是将测试结果添加到测试运行中,而不是更新测试运行中的测试结果。你应该参考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,然后将您要更新的测试结果捕获到更新API,并在那里修改值。

    https://{account}.visualstudio.com/{teamproject}/_apis/test/runs/{run}/results?api-version=3.0-preview
    

    【讨论】:

      【解决方案2】:

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

      [
            {
              "testPoint":{
                  "id":144
              },
               "priority": 1,
               "outcome": "failed"
            }
         ]
      

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

      【讨论】:

        【解决方案3】:

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-10-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-11-30
          • 1970-01-01
          • 2018-03-23
          • 1970-01-01
          相关资源
          最近更新 更多