简体   繁体   中英

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.

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

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:

在此处输入图片说明

If you want to use api, you would need to follow the steps below:

  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:

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:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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