添加测试结果并参考测试计划、测试套件、测试用例不工作 "ShallowReference" 使用 azure rest api

Add Test Results with references to Test Plan, Test Suite, Test Case not working "ShallowReference" using azure rest api

我正在使用 Azure DevOps Services REST API 5.1 在我的 DevOps 测试计划中创建测试 运行。

我首先创建一个测试 运行 就像 documents here

邮递员请求:

POST /{Organization}/{project}/_apis/test/runs?api-version=5.0 HTTP/1.1 Host: dev.azure.com 
Authorization: Basic xyz
Content-Type: application/json    
    {
        "name": "koko",
        "automated": true 
    }

然后我将测试结果添加到之前创建的测试中 运行。 doc.

邮递员请求:

POST /{organization}/{project}/_apis/test/Runs/240/results?api-version=5.0 HTTP/1.1
Host: dev.azure.com
Authorization: Basic xyz
Content-Type: application/json

[
  {
    "Project": {
      "Id": "xxxxxxxx-xxxx-xxxx-xxxx-c748b3ba25f6",
      "Name": "Project",
      "Url": "https://dev.azure.com/xx/_apis/projects/xxxxxxxx-xxxx-xxxx-xxxx-c748b3ba25f6"
    },
    "StartedDate": "2020-07-07T16:25:56.4171217+03:00",
    "DurationInMs": 550,
    "Outcome": "Passed",
    "State": "Completed",
    "TestCase": {
      "Id": "6304",
      "Name": "TestCase",
      "Url": "https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/6302/Suites/6303/TestCase/6304"
    },
    "TestRun": {
      "Id": "240",
      "Name": "koko",
      "Url": "https://dev.azure.com/{organization}/{project}/_apis/test/Runs/240"
    },
    "Priority": 2,
    "CreatedDate": "2020-07-07T16:24:56.4171092+03:00",
    "TestCaseTitle": "TEST8",
    "TestPlan": {
      "Id": "6302",
      "Name": "Template",
      "Url": "https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/6302"
    },
    "TestSuite": {
      "Id": "6303",
      "Name": "Template",
      "Url": "https://dev.azure.com/{organization}/{project}/testplan/Plans/6302/Suites/6303"
    },
    "AutomatedTestName": "TEST8"
  }
]

我遇到的问题是创建的测试结果没有显示引用的测试计划、测试用例 ID 和测试套件。

当前结果:

预期结果:

此外,您需要Test points of your test case and work item info (revision)

这是一个例子:

  1. 使用计划的测试点创建测试运行:

    https://dev.azure.com/{org}/{teamproject}/_apis/test/runs?api-version=5.1
    {
     "name": "NewTestRun",
     "automated": true, 
       "plan": {
     "id": "103"
     },
     "pointIds": [3]
    }
    
  2. 添加测试结果:

    https://dev.azure.com/{org}/{teamproject}/_apis/test/Runs/{RunId}/results?api-version=5.1
    
    [
     {
         "Priority": 2,  
         "State": "Completed",
         "outcome": "Passed",    
         "testCaseRevision": 3,
         "testCaseTitle": "Test 1",
         "testCase":
         {            
             "id": "106"
         },
         "testPoint":
         {            
             "id": "3"
         },
         "AutomatedTestName": "TEST8"
     }
    ]