Changing the outcome field of testcases within a test suite in Tfs

余生长醉 提交于 2019-12-02 08:08:39

Seems you want to update the test result. You need to get the test run ID first.

You can use the REST API to update the specific test result. Please see Update test results for a test run for details.

PATCH https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}

You can also use TFS API, for example:

TfsTeamProjectCollection teamCollection;
            ITestManagementService service;
            ITestManagementTeamProject project;
            var picker = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);
            picker.ShowDialog();
            if (picker.SelectedTeamProjectCollection != null && picker.SelectedProjects != null)
            {
                teamCollection = picker.SelectedTeamProjectCollection;
                service = teamCollection.GetService<ITestManagementService>();
                project = service.GetTeamProject(picker.SelectedProjects.First().Name);
            }
            else
            {
                return;
            }

//Get Test result
 var testResults = project.TestResults.ByTestId([test case id]);

 // iterate each result for the case
 foreach (ITestCaseResult result in testResults)
 {
     //TODO other code
     //update result
     result.Outcome = TestOutcome.Failed;
     result.Save(true);
}

Reference this thread : How to update the test case result in MTM using C#

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!