我已安排从TFS每天运行的回归自动化,我想开发功能,仅针对最新版本运行失败的测试用例,而不是再次使用整个回归自动化。
有没有办法,我只能调用web api并只传递失败的测试用例名称,当我触发部署到任何只会运行的环境时
或者还有其他方法吗?
答案 0 :(得分:0)
构建定义中的the v2.* of the VSTest task中已有Rerun failed tests
选项,您可以选择此选项以重新运行失败的测试:
如果您想使用api,则需要按照以下步骤操作:
GET https://{accountName}.visualstudio.com/{project}/_apis/test/Runs/{runId}/results?api-version=5.0-preview.5
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 )"
}