简体   繁体   English

在TFS上运行随机测试用例

[英]Run random test cases on TFS

I have schedule regression automation that is running everyday from TFS, I want to develop functionality to run only failed test case against latest build not whole regression automation again. 我有从TFS每天运行的计划回归自动化,我想开发功能以针对最新版本仅运行失败的测试用例,而不是再次运行整个回归自动化。

Is there a way, I can only call web api and pass only failed test case name and when I trigger deploy to any environment that will only run 有没有办法,我只能调用Web api并仅通过失败的测试用例名称,并且当我触发部署到将仅运行的任何环境时

Or is there any other way around this. 还是有其他解决方法。

There is already a Rerun failed tests option in the v2.* of the VSTest task in the build definition, you could select this option to rerun the failed tests: 在构建定义的VSTest任务的v2。*版本中已经存在“ Rerun failed tests选项,您可以选择以下选项来重新运行失败的测试:

在此处输入图片说明

If you want to use api, you would need to follow the steps below: 如果要使用api,则需要按照以下步骤操作:

  1. Get test results for a test run and find out the failed test cases. 获取测试运行的测试结果,并找出失败的测试用例。

GET https://{accountName}.visualstudio.com/{project}/_apis/test/Runs/{runId}/results?api-version=5.0-preview.5

  1. Create a new test suite by querying the failed test case IDs: 通过查询失败的测试用例ID来创建新的测试套件

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. Select Test Plan and Test suite in your VSTest task: 在VSTest任务中选择“测试计划”和“测试套件”:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM