小编Dir*_*sel的帖子

在TFS API中将测试用例添加到ITestSuiteBase

我正在使用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();
Run Code Online (Sandbox Code Playgroud)

但是,此解决方案不适用于需求测试套件或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();
Run Code Online (Sandbox Code Playgroud)

但是这种方法实际上并没有将测试用例添加到套件中.但是,它确实将测试用例添加到计划中.我可以查询创建的测试用例,但它没有按预期显示在套件中 - 即使在代码之后也是如此.刷新工作套房没有任何好处.

其他代码如下:

    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;
    }
Run Code Online (Sandbox Code Playgroud)

有没有人能够成功地将测试用例添加到需求测试套件或ITestSuiteBase中?

c# tfs test-suite testcase visual-studio-2013

5
推荐指数
1
解决办法
3057
查看次数

标签 统计

c# ×1

test-suite ×1

testcase ×1

tfs ×1

visual-studio-2013 ×1