我正在使用 TFS API,并遇到了 ITestSuiteBase 和 IRequirementTestSuite 的问题。我设法在 IStaticTestSuite 中轻松创建一个新的测试用例:
IStaticTestSuite workingSuite = this.WorkingSuite as IStaticTestSuite;
testCase = CreateTestCase(this.TestProject, tci.Title, tci.Description);
workingSuite.Entries.Add(testCase);
this.Plan.Save();
但是,此解决方案不适用于需求测试套件或 ITestSuiteBase。我认为可行的方法是:
ITestcase testCase = null;
testCase = CreateTestCase(this.TestProject, tci.Title, tci.Description);
this.WorkingSuite.AllTestCases.Add(testCase);
this.WorkingSuite.TestCases.Add(testCase);
this.Plan.Save();
但此方法实际上并未将测试用例添加到套件中。然而,它确实将测试用例添加到计划中。我可以查询创建的测试用例,但它没有按预期显示在套件中 - 即使之后立即显示在代码中。刷新工作套件没有任何好处。
附加代码如下:
public static ITestCase CreateTestCase(ITestManagementTeamProject project, string title, string desc = "", TeamFoundationIdentity owner = null)
{
// Create a test case.
ITestCase testCase = project.TestCases.Create();
testCase.Owner = owner;
testCase.Title = title;
testCase.Description = desc;
testCase.Save();
return testCase;
}
有没有人能够成功地将测试用例添加到需求测试套件或 ITestSuiteBase 中?