0

这是第一步

IStaticTestSuite testSuite = _teamProject.TestSuites.CreateStatic();
// create an empty test suite below
IStaticTestSuite mtmTestSuite = _teamProject.TestSuites.CreateStatic(); 

我想在mtmTestSuite里面添加,testsuite因为我们可以手动添加。

4

2 回答 2

0

试试下面的代码:

ITestPlanCollection plans = testproject.TestPlans.Query("Select * From TestPlan");
            var p = plans.Where(pp => pp.Name == "Plan1").First();
            IStaticTestSuite newSuite = testproject.TestSuites.CreateStatic();
            newSuite.Title = "Acceptance Tests";
            IStaticTestSuite pSuite = p.RootSuite.Entries.Where(s => s.Title == "WindowsFormDemoTest").First().TestSuite as IStaticTestSuite;
            pSuite.Entries.Add(newSuite);
           // p.RootSuite.Entries.Add(newSuite);
            p.Save();

您可以通过以下链接引用“添加新 TFS 测试套件”部分的更多方法:管理 TFS 测试套件 C# 代码

于 2016-06-30T06:01:34.020 回答
0

如果您同时创建 testSuite 和 mtmTestSuite,您只需要在 testSuite 创建并添加到 Test Plan/Suite 后添加一行代码即可将 mtmTestSuite 添加到 testSuite 中:

testSuite.Entries.Add(mtmTestSuite);

如果 testSuite 已经存在,那么您需要先获取 testSuite,然后将 mtmTestSuite 添加到其中。例如:

    IStaticTestSuite testSuite = itmtp.TestSuites.CreateStatic();
    foreach (IStaticTestSuite ts in itmtp.TestSuites.Query("Select * From TestSuite"))
    {
        if (ts.Id == 103)//Get the test suite by ID
        {
            testSuite = ts;
        }
    }
    IStaticTestSuite mtmTestSuite = itmtp.TestSuites.CreateStatic();
    mtmTestSuite.Title = "Title";
    testSuite.Entries.Add(mtmTestSuite);
于 2016-07-06T02:57:01.660 回答