C# 如何以编程方式在VSTS/TFS的testcase中向每个测试步骤添加/更新单个结果
我能够通过这个程序在VSTS中将测试结果更新为testcase。C# 如何以编程方式在VSTS/TFS的testcase中向每个测试步骤添加/更新单个结果,c#,tfs,tfs-2015,azure-devops-rest-api,C#,Tfs,Tfs 2015,Azure Devops Rest Api,我能够通过这个程序在VSTS中将测试结果更新为testcase。 现在,我想更新测试用例中每个测试步骤的结果。找不到任何相关信息。请帮助简单的方法是使用客户端API: 简单示例: int testpointid = 176; var u = new Uri("https://[account].visualstudio.com"); VssCredentials c = new VssCredentials(new Microsoft.Visua
现在,我想更新测试用例中每个测试步骤的结果。找不到任何相关信息。请帮助简单的方法是使用客户端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);
关于RESTAPI,必要的信息存储在iterationDetails(TestCaseResult.iterationDetails)的actionResults中,您可以尝试指定iterationDetails到TestCaseResult并更新测试结果
您可以使用(detailsToInclude=Iterations)检查测试结果的详细信息。如何查看测试用例中的各个测试步骤结果?在列出的测试套件的“结果”列中,我只能找到测试用例/测试运行的最终结果,但找不到每个测试步骤的测试结果。@srinivasp获得测试步骤结果的多种方法:1。正如我所说的,使用DetailInclude 2获得测试结果。Web访问,测试>运行>输入测试运行>转到>测试结果>双击测试结果>签入详细信息>3。MTM,打开MTM并连接到TFS,然后选择测试计划>测试>运行测试>选择测试套件>选择测试点>单击查看结果最后,使用已解决的错误。我可以在测试用例中更新每个测试步骤的结果。你用我的解决方案解决了这个问题吗?@starain MSFT-很抱歉,更新延迟了。我们已经试过你的解决办法了。遇到错误TypeLoadException未处理。错误读取为<代码>无法从程序集“微软.Team Foundation”中加载“微软.Team Foundation,TfStRealPrimeRever”。常见的< /代码>有什么建议吗?您使用微软Team Foundation Server扩展客户端包吗?您能不能简单地使用OnDeRiVE?我正在使用。而不是使用微软Team Foundation Server扩展客户端。