本文介绍了无法将测试用例添加到 IRequirementTestSuite 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 TFS API 创建了一个测试用例工作项.当我尝试将测试用例发送到 IStaticTestSuite 时,它​​成功了.

I have created a test case workitem using TFS API.When i am trying to the test case to IStaticTestSuite it was successfull.

  if (firstMatchingSuite.TestSuiteType == TestSuiteType.StaticTestSuite)
           ((IStaticTestSuite)firstMatchingSuite).Entries.Add(testCase);

但我无法使用以下代码向 IRequirementTestSuite 添加测试用例.我收到无法添加或删除测试用例"错误.

But i am not able to add a test case to IRequirementTestSuite using the below code.I get "Cannot add or remove test cases" error.

   if (firstMatchingSuite.TestSuiteType == TestSuiteType.RequirementTestSuite)
          ((IRequirementTestSuite)firstMatchingSuite).TestCases.Add(testCase);

有什么建议吗?

推荐答案

是.

我发现的唯一方法是通过 TFS API 本身(仅使用您编写的内容):

The only way I found is via the TFS API as such (Using only what you wrote you have):

var store = ((IRequirementTestSuite)firstMatchingSuite).Project.WitProject.Store;
var tfsRequirement = store.GetWorkItem(((IRequirementTestSuite)firstMatchingSuite).RequirementId);

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

((IRequirementTestSuite)firstMatchingSuite).Repopulate();

它有效,我检查过!

享受:)

这篇关于无法将测试用例添加到 IRequirementTestSuite 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 18:14