问题
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