我可以通过程序将测试结果更新到VSTS中的测试用例。 Test Case Result Updation如何以编程方式在VSTS/TFS的测试用例中添加/更新单个结果到每个测试步骤
现在,我想更新测试用例中每个测试步骤的结果。找不到任何相关信息。请帮助
我可以通过程序将测试结果更新到VSTS中的测试用例。 Test Case Result Updation如何以编程方式在VSTS/TFS的测试用例中添加/更新单个结果到每个测试步骤
现在,我想更新测试用例中每个测试步骤的结果。找不到任何相关信息。请帮助
最简单的方法是使用客户端API:
简单的例子:
int testpointid = 176;
var u = new Uri("https://[account].visualstudio.com");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "[pat]"));
TfsTeamProjectCollection _tfs = new TfsTeamProjectCollection(u, c);
ITestManagementService test_service = (ITestManagementService)_tfs.GetService(typeof(ITestManagementService));
ITestManagementTeamProject _testproject = test_service.GetTeamProject("scrum2015");
ITestPlan _plan = _testproject.TestPlans.Find(115);
ITestRun testRun = _plan.CreateTestRun(false);
testRun.Title = "apiTest";
ITestPoint point = _plan.FindTestPoint(testpointid);
testRun.AddTestPoint(point, test_service.AuthorizedIdentity);
testRun.Save();
testRun.Refresh();
ITestCaseResultCollection results = testRun.QueryResults();
ITestIterationResult iterationResult;
foreach (ITestCaseResult result in results)
{
iterationResult = result.CreateIteration(1);
foreach (Microsoft.TeamFoundation.TestManagement.Client.ITestStep testStep in result.GetTestCase().Actions)
{
ITestStepResult stepResult = iterationResult.CreateStepResult(testStep.Id);
stepResult.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed; //you can assign different states here
iterationResult.Actions.Add(stepResult);
}
iterationResult.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed;
result.Iterations.Add(iterationResult);
result.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed;
result.State = TestResultState.Completed;
result.Save(true);
}
testRun.State = Microsoft.TeamFoundation.TestManagement.Client.TestRunState.Completed;
results.Save(true);
关于REST API,必要的信息存储在actionResults 的 iterationDetails(TestCaseResult.IterationDetails) ,您可以尝试指定IterationDetails至TestCaseResult并更新测试结果。
您可以通过使用Get a Test Result with DetailInclude检查测试结果的细节(detailsToInclude =迭代)
如何查看测试用例中的单个测试步骤结果?我只能找到列出的测试套件的结果列中的测试用例/测试运行的最终结果,但找不到每个测试步骤的测试结果。 –
@srinivasp许多获得测试步骤结果的方法:1.正如我所说的使用获取测试结果和DetailInclude 2. Web访问,测试>运行>输入测试运行>去>测试结果>双击测试结果>检查详细信息> 3. MTM,打开MTM并连接到TFS并选择测试计划>测试>运行测试>选择测试套件>选择测试点>单击查看结果 –
最后,使用[Microsoft Team Foundation Server Extended Client](https ://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient/)解决了错误。我能够更新测试用例中每个测试步骤的结果。 –
你解决我的解决方案的问题? –
@ starain-MSFT - 对不起,为延迟更新。我们已经尝试了您的解决方遇到错误** TypeLoadException未处理**。错误读为 '无法从程序集'Microsoft.TeamFoundation.Common'加载类型'Microsoft.TeamFoundation.TFStringComparer' 有什么建议吗? –
您是否使用Microsoft Team Foundation Server Extended Client软件包?你可以在OneDrive上做一个简单的项目吗? –