I am working with the TFS API and have encountered a problem with ITestSuiteBase and IRequirementTestSuite. I managed to easily create a new test case in IStaticTestSuite:
IStaticTestSuite workingSuite = this.WorkingSuite as IStaticTestSuite;
testCase = CreateTestCase(this.TestProject, tci.Title, tci.Description);
workingSuite.Entries.Add(testCase);
this.Plan.Save();
However, this solution does not work for requirements test suites or ITestSuiteBase. The method I would suggest would work:
ITestcase testCase = null;
testCase = CreateTestCase(this.TestProject, tci.Title, tci.Description);
this.WorkingSuite.AllTestCases.Add(testCase);
this.WorkingSuite.TestCases.Add(testCase);
this.Plan.Save();
But this method does not actually add a test case to the package. However, he adds a test case to the plan. I can request the created test case, but it does not appear in the package as expected, even immediately in the code. Updating a work package will not be useful.
Additional code below:
public static ITestCase CreateTestCase(ITestManagementTeamProject project, string title, string desc = "", TeamFoundationIdentity owner = null)
{
ITestCase testCase = project.TestCases.Create();
testCase.Owner = owner;
testCase.Title = title;
testCase.Description = desc;
testCase.Save();
return testCase;
}
Has anyone been able to successfully add a test case to the requirements test suite or ITestSuiteBase?