【问题标题】:Adding a TestCase to a SubSuite (ITestSuiteBase)将测试用例添加到 SubStitute (ITestSuiteBase)
【发布时间】:2015-09-21 13:24:11
【问题描述】:

我正在尝试将测试用例添加到测试套件中。

MTM 中的布局如下:

-Top TestCase
    - Test Feature
       - New TestCase

所以我想添加New TestCase

我有SubSuits,它列出了Test Feature,并且是ITestSuiteBase,但我无法向其中添加任何内容。抛出异常,消息为:Cannot add, remove or change items

public void CopyTestCaseIntoTestSuite(ITestCase sourceTestCase)
{
    // SelectedSubSuite is typeof ITestSuiteBase
    SelectedSubSuit.TestCases.Add(sourceTestCase); // Fails here
}

还有其他人能够添加到ITestSuiteBase吗?

【问题讨论】:

  • 您是否将功能添加为基于需求的类型?如果是这样,您需要静态套装才能手动添加!
  • 对不起。我对 TFS Api 很陌生,你有什么例子吗?
  • 您是否创建了基于静态或回报的套装?您不能使用 TestCases.Add 一个需求!

标签: c# tfs


【解决方案1】:

ITestSuiteBase.TestCases属性是只读的,所以不允许用代码添加一个测试用例:SelectedSubSuit.TestCases.Add(sourceTestCase);

您需要改用以下代码:

IStaticTestSuite staticTestSuite = SelectedSubSuit as IStaticTestSuite;
staticTestSuite.Entries.Add(sourceTestCase);
this.Plan.Save();

【讨论】:

猜你喜欢
  • 2014-12-08
  • 1970-01-01
  • 2012-06-03
  • 1970-01-01
  • 1970-01-01
  • 2019-06-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多