【发布时间】:2020-06-28 12:25:48
【问题描述】:
我无法找到在 C# 中获取给定版本的测试结果的方法。
我之前所做的是,通过构建 ID 获取测试结果。
这是一个示例代码
int buildId = 123;
const string TFS_url = "<TFS_URL>";
string projectname = "<Teamname>";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(TFS_url));
// Get build information
BuildHttpClient bhc = ttpc.GetClient<BuildHttpClient>();
// Get testrun for the build
TestManagementHttpClient ithc = ttpc.GetClient<TestManagementHttpClient>();
QueryModel qm = new QueryModel("Select * From TestRun Where BuildNumber Contains '" + buildId + "'");
List<TestRun> testruns = ithc.GetTestRunsByQueryAsync(qm, projectname).Result;
List<List<TestCaseResult>> allTestresults = new List<List<TestCaseResult>>();
foreach (TestRun testrun in testruns)
{
List<TestCaseResult> testresults = ithc.GetTestResultsAsync(projectname, testrun.Id).Result;
allTestresults.Add(testresults);
}
我更喜欢在 C# 中使用给定的类,而不必通过 API 来完成。
【问题讨论】:
标签: c# .net tfs azure-devops tfs-sdk