我试图使用TFS API来更新单独运行的自动化测试结果。我尝试了其他问题的建议(特别是How to create a test run and result using the Team Foundation Server API?)以及其他地方的搜索。不管我怎么努力我有同样的问题:每次我试图将一个测试点添加到试运行的时候,我收到错误 -TFS 2012 API:无法将测试点添加到测试运行
Microsoft.TeamFoundation.TestManagement.Client.TestManagementInvalidOperationException: This test run cannot be created with the test points.
测试点由TFS使用WIQL检索,和我检查每个测试点在我尝试添加测试计划,测试套件和测试配置之前要确保它是正确的。
我无法保存没有测试点的测试运行。
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();
}
我能:
示例代码
public void UpdateTests(TestSuiteRun suiteRun)
{
this.Config = FindConfig(suiteRun.Description);
this.Suite = FindSuite(suiteRun.Name);
this.Plan = Suite.Plan;
this.Points = FindPoints(this.Suite.Id, this.Config.Id);
ITestCaseCollection testCases = Suite.AllTestCases;
this.Run = TeamProject.TestRuns.Create();
ConfigureTestRun(); // failing here
this.Result = CreateRunResults();
this.Iteration = CreateSingleIteration(suiteRun.Description);
{
UpdateResultsForScenario(scen);
}
}
而且方法来配置试运行(我已经经历了这么多努力,现在我的代码已经超出了凌乱)连接到TFS并检索我需要的所有数据,但将测试点添加到新的测试运行正在让我发疯。
我做错了什么?
什么是“保存”的回报,如果它是一个布尔值,什么是结果? – DaveShaw
@DaveShaw我没有去“保存” - 例程在Run.AddTestPoint()上失败。 –