How can I link a test case as a “tested user story” with the Microsoft.TeamFoundation API? RRS feed

  • Question

  • I'm writing a console application in C# using the Microsoft.TeamFoundation classes to connect to a Visual Studio Team Foundation Server 2015 on-premises instance.

    My application needs to create/upload test cases and link them to existing user stories. If I use the RelatedLink class and add it to the ITestCase.Links property, when I view the test case through the web portal, the links appear under the All Links tab, and not the Tested User Stories tab.

    How can I go about linking test cases and stories so that they appear in the Tested User Stories tab instead?

    Thursday, August 2, 2018 1:49 AM

All replies

  • Hi,

    You might be not using correct link types.

    Please try below line of code - 

    workItemStore = (WorkItemStore)teamProjectCollection.GetService(typeof(WorkItemStore));
    WorkItem sourceWt = workItemStore.GetWorkItem(ID);
    WorkItemLinkType linkType = workItemStore.WorkItemLinkTypes["Microsoft.VSTS.Common.TestedBy"];
                    WorkItemLinkTypeEnd linkTypeEnd = workItemStore.WorkItemLinkTypes.LinkTypeEnds[linkType.ForwardEnd.Name];
    sourceWt.Links.Add(new RelatedLink(linkTypeEnd,userStoryID ));

    Vivek Bansod
    Blog | MSDN | LinkedIn

    Friday, August 3, 2018 8:01 AM