在Tfs中的测试套件中更改测试用例的结果字段 [英] Changing the outcome field of testcases within a test suite in Tfs
问题描述
给出一个测试套件ID,是否可以在Tfs中更改其中的测试用例的结果?
例如,将活动状态更改为通过状态或进入失败状态。
当使用测试套件迭代测试用例时,我找不到名称为result的字段。我们如何修改结果字段?
似乎要更新测试结果。您需要首先获取测试运行ID。
您可以使用REST API更新特定的测试结果。请参阅
Given a Test Suite id, is it possible to change the outcome of the test cases within it in Tfs ?
For instance , changing the active state to pass state or to failed state.
While iterating through the test cases with a test suite, i couldnt find a field by the name outcome. How can we modify the outcome field?
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#
这篇关于在Tfs中的测试套件中更改测试用例的结果字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!