Tfs sdk TFS 2012 API:无法将测试点添加到测试运行
我正在尝试使用TFSAPI来更新单独运行的自动化测试结果。我在这里(特别是)尝试了其他问题的建议,以及其他地方的搜索。无论我尝试什么,我都会遇到同样的问题:每次我尝试向测试运行添加测试点时,我都会收到错误-Tfs sdk TFS 2012 API:无法将测试点添加到测试运行,tfs-sdk,Tfs Sdk,我正在尝试使用TFSAPI来更新单独运行的自动化测试结果。我在这里(特别是)尝试了其他问题的建议,以及其他地方的搜索。无论我尝试什么,我都会遇到同样的问题:每次我尝试向测试运行添加测试点时,我都会收到错误- Microsoft.TeamFoundation.TestManagement.Client.TestManagementInvalidOperationException: This test run cannot be created with the test points. 使用W
Microsoft.TeamFoundation.TestManagement.Client.TestManagementInvalidOperationException: This test run cannot be created with the test points.
使用WIQL从TFS检索测试点,在尝试添加测试点之前,我检查每个测试点以确保它对于测试计划、测试套件和测试配置是正确的
没有测试点,我无法保存测试运行
示例代码(我已经尝试了很多次,现在我的代码已经不再凌乱)
以及配置测试运行的方法:
private void ConfigureTestRun()
{
this.Run.DateStarted = DateTime.Now;
this.Run.DateCompleted = DateTime.Now;
// find the points that correspond to test cases in the run suite
foreach (ITestPoint point in this.Points)
{
if (point.TestCaseExists && point.Plan.Id == this.Plan.Id && point.ConfigurationId == this.Config.Id)
{
this.Run.AddTestPoint(point, this.CurrentUser); // fails with InvalidOperationException
}
}
this.Run.Save();
}
我能够连接到TFS并检索我需要的所有数据,但向新的测试运行添加测试点让我抓狂
我做错了什么 经过疯狂的实验和撞墙,我找到了答案 对于那些好奇的人,以下是它的工作原理:
- 如果我使用
ITestManagementService.TestRuns.Create()代码>我可以添加测试用例,但是 不是测试点
- 如果我使用
ITestPlan.CreateTestRun(自动)代码>我可以添加测试点,但不能 测试用例
this.Run = this.Plan.CreateTestRun(false);
ConfigureTestRun(build);
this.Result = CreateRunResults();
this.Iteration = CreateSingleIteration(suiteRun.Description);
// custom processing omitted for brevity
this.Result.Iterations.Add(this.Iteration);
// Attach the run log to the results
ITestAttachment item = this.Iteration.CreateAttachment(ConfigurationManager.AppSettings["LogFile"], SourceFileAction.None);
this.Result.State = TestResultState.Completed;
this.Result.Save();
this.Run.Attachments.Add(item);
this.Run.Save();
测试运行配置例行程序为:
private void ConfigureTestRun(IBuildDetail build)
{
this.Run.DateStarted = DateTime.Now;
this.Run.DateCompleted = DateTime.Now;
this.Run.BuildDirectory = build.DropLocation;
this.Run.BuildFlavor = "debug";
this.Run.BuildNumber = build.BuildNumber;
this.Run.BuildPlatform = "test platform";
this.Run.BuildUri = build.Uri;
this.Run.Controller = build.BuildController.Name;
// find the points that correspond to test cases in the run suite
foreach (ITestPoint point in this.Points)
{
if (point.TestCaseExists && point.Plan.Id == this.Plan.Id && point.ConfigurationId == this.Config.Id)
{
this.Run.AddTestPoint(point, this.CurrentUser);
}
}
this.Run.Save();
}
“Save”返回什么,如果是Bool,结果是什么?@DaveShaw我不能“Save”-例程在Run.AddTestPoint()时失败。
private void ConfigureTestRun(IBuildDetail build)
{
this.Run.DateStarted = DateTime.Now;
this.Run.DateCompleted = DateTime.Now;
this.Run.BuildDirectory = build.DropLocation;
this.Run.BuildFlavor = "debug";
this.Run.BuildNumber = build.BuildNumber;
this.Run.BuildPlatform = "test platform";
this.Run.BuildUri = build.Uri;
this.Run.Controller = build.BuildController.Name;
// find the points that correspond to test cases in the run suite
foreach (ITestPoint point in this.Points)
{
if (point.TestCaseExists && point.Plan.Id == this.Plan.Id && point.ConfigurationId == this.Config.Id)
{
this.Run.AddTestPoint(point, this.CurrentUser);
}
}
this.Run.Save();
}