Not able to add test cases to type of IRequirementTestSuite

不羁的心 提交于 2019-12-11 09:38:29

问题


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);

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);

Any suggestions ?


回答1:


Yes.

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();

It works, I checked!

Enjoy :)



来源:https://stackoverflow.com/questions/12457532/not-able-to-add-test-cases-to-type-of-irequirementtestsuite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!