gpt4 book ai didi

c# - 如何以编程方式向 VSTS/TFS 测试用例中的每个测试步骤添加/更新单个结果

转载 作者:行者123 更新时间:2023-11-30 21:40:20 24 4
gpt4 key购买 nike

我可以通过程序将测试结果更新到 VSTS 中的测试用例。 Test Case Result Updation

现在,我想更新测试用例中每个测试步骤的结果。找不到任何相关信息。请帮忙

最佳答案

简单的方法是使用客户端 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,必要的信息存储在iterationDetailsactionResults中(TestCaseResult.IterationDetails),你可以尝试指定IterationDetails到< strong>TestCaseResult 并更新测试结果。

您可以使用 Get a Test Result with DetailInclude 查看测试结果的详细信息(detailsToInclude=迭代次数)

关于c# - 如何以编程方式向 VSTS/TFS 测试用例中的每个测试步骤添加/更新单个结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44697226/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com