我正在尝试通过TFS将测试结果发布到Microsoft Test Manager,但是在尝试通过TFS API发布结果时出现以下错误:
Microsoft.TeamFoundation.TestManagement.Client.TestObjectNotFoundException:
Build vstfs:///Build/Build/### cannot be found.
我正在制定测试计划并创建测试运行the way Microsoft suggests:
plan = teamProject.TestPlans.Query(
"SELECT * FROM TestPlan WHERE PlanName = '" + planName + "')[0];
ITestRun run = plan.CreateTestRun(true);
run.AddTestPoints(testPoints, null);
run.Save();
那么为什么说无法找到构建?
答案 0 :(得分:1)
定期从系统中清除构建,因此您可能希望确定自己using the latest build。然后,您可以获取最新的构建URI并将其与您的运行相关联。
Uri GetLatestBuildURI(string projectName) {
Uri buildUri = null;
IBuildServer buildServer = _tfs.GetService<IBuildServer>();
IBuildDetailSpec detailSpec = buildServer.CreateBuildDetailSpec(projectName);
detailSpec.MaxBuildsPerDefinition = 1;
detailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending;
IBuildQueryResult results = buildServer.QueryBuilds(detailSpec);
if (results.Builds.Length == 1) {
IBuildDetail detail = results.Builds[0];
buildUri = detail.Uri;
}
return buildUri;
}
...
ITestRun run = plan.CreateTestRun(true);
run.BuildUri = GetLatestBuildURI(projectName);
run.AddTestPoints(testPoints, null);
run.Save();