Add test case to ITestSuiteBase in TFS API

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)
    {
        // Create a test case.
        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?

+4
2

Giulio

testCase = CreateTestCase(this.TestProject, tci.Title, tci.Description);
if (this.BaseWorkingSuite is IRequirementTestSuite)
    TFS_API.AddTestCaseToRequirementSuite(this.BaseWorkingSuite as IRequirementTestSuite, testCase);
else if (this.BaseWorkingSuite is IStaticTestSuite)
    (this.BaseWorkingSuite as IStaticTestSuite).Entries.Add(testCase);
this.Plan.Save();

:

public static void AddTestCaseToRequirementSuite(IRequirementTestSuite reqSuite, ITestCase testCase)
{
    WorkItemStore store = reqSuite.Project.WitProject.Store;
    WorkItem tfsRequirement = store.GetWorkItem(reqSuite.RequirementId);

    tfsRequirement.Links.Add(new RelatedLink(store.WorkItemLinkTypes.LinkTypeEnds["Tested By"], testCase.WorkItem.Id));
    tfsRequirement.Save();

    reqSuite.Repopulate();
}
+5

.

Static Test Suites ... , , , . / , ​​.

. IRequirementTestSuite.

: , , .

+4

All Articles