我想获取链接到测试用例的用户故事。我有测试用例的详细信息,但想在c#中通过它获取链接的用户故事。
无法在线找到任何有用的参考资料。
答案 0 :(得分:0)
您可以尝试以下代码剪切:
WorkItemStore workItemStore = teamProjectCollection.GetService<WorkItemStore>();
var workItem = workItemStore.GetWorkItem(testCaseId);
List<WorkItem> wilist = new List<WorkItem>();
foreach (WorkItemLink wiLink in workItem.WorkItemLinks)
{
if (wiLink.LinkTypeEnd.Name.Equals("Tests"))
{
int targetId = wiLink.TargetId;
var linkedWI = workItemStore.GetWorkItem(targetId);
if (linkedWI.Fields["Work Item Type"].Value.ToString() == "User Story")
{
wilist.Add(linkedWI); // Add the user story to the list
}
}
}
您也可以使用此TFS REST API:
GET http://serverName:8080/tfs/DefaultCollection/_apis/wit/workitems/309?$expand=relations&api-version=1.0
关于在C#中使用它,请参考: https://www.visualstudio.com/en-us/docs/integrate/api/wit/work-items#with-links-and-attachments-1