在TFS

时间:2018-05-03 21:25:56

标签: asp.net selenium tfs automation nunit

我已安排从TFS每天运行的回归自动化,我想开发功能,仅针对最新版本运行失败的测试用例,而不是再次使用整个回归自动化。

有没有办法,我只能调用web api并只传递失败的测试用例名称,当我触发部署到任何只会运行的环境时

或者还有其他方法吗?

1 个答案:

答案 0 :(得分:0)

构建定义中的the v2.* of the VSTest task中已有Rerun failed tests选项,您可以选择此选项以重新运行失败的测试:

enter image description here

如果您想使用api,则需要按照以下步骤操作:

  1. Get test results for a test run并找出失败的测试用例。
  2. GET https://{accountName}.visualstudio.com/{project}/_apis/test/Runs/{runId}/results?api-version=5.0-preview.5

    1. Create a new test suite通过查询失败的测试用例ID:
    2. POST https://{accountName}.visualstudio.com/{project}/_apis/test/Plans/{planId}/suites/{suiteId}?api-version=5.0-preview.3

      Content-Type:application/json

      { "suiteType": "DynamicTestSuite", "name": "FailedTestCases", "queryString": "SELECT [System.Id],[System.WorkItemType],[System.Title],[Microsoft.VSTS.Common.Priority],[System.AssignedTo],[System.AreaPath] FROM WorkItems WHERE [System.TeamProject] = @project AND [System.WorkItemType] IN GROUP 'Microsoft.TestCaseCategory' AND ( [System.Id] = xxx OR [System.Id] = xxx )" }

      1. 在VSTest任务中选择测试计划和测试套件:
      2. enter image description here