【发布时间】:2013-06-27 02:50:59
【问题描述】:
我正在尝试使用 TFS API 从单独运行的自动化中更新测试结果。我已经尝试过这里其他问题的建议(特别是How to create a test run and result using the Team Foundation Server API?)以及其他地方的搜索。无论我尝试什么,我都会遇到同样的问题:每次我尝试将测试点添加到测试运行时,我都会收到错误 -
Microsoft.TeamFoundation.TestManagement.Client.TestManagementInvalidOperationException: This test run cannot be created with the test points.
测试点是使用 WIQL 从 TFS 检索的,我会检查每个测试点以确保在尝试添加测试计划、测试套件和测试配置之前它是正确的。
如果没有测试点,我无法保存测试运行。
示例代码(我已经经历了如此多的尝试,以至于我的代码现在已经凌乱不堪了)
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);
}
}
以及配置测试运行的方法:
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 并检索我需要的所有数据,但是在新的测试运行中添加测试点让我发疯。
我做错了什么?
【问题讨论】:
-
“保存”返回什么,如果是Bool,结果是什么?
-
@DaveShaw 我没有进入“保存” - 例程在 Run.AddTestPoint() 上失败。
标签: tfs-sdk