经过BY(19)测试
根据测试,有19个测试用例。
如果给出了用户故事的ID,则如何获取这些测试用例。
如果(链接链接是相关的)返回所有链接。
如何获取测试用例。
任何帮助将不胜感激。我刚刚开始使用c#
处理tfs答案 0 :(得分:0)
您可以使用TFS REST API来获取所需的信息,Microsoft.VSTS.Common.TestedBy-Forward
关系是TestedBy链接类型。 API如下:
GET https://{account}.visualstudio.com/{project}/_apis/wit/workitems/{id}?$expand=Relations&api-version=5.0-preview.3
以下屏幕截图是REST API的响应:
这里是一个带有客户端库的示例,可以从用户案例中获取测试用例ID,以供您参考:
using System;
using Microsoft.VisualStudio.Services.Client;
using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
namespace GetWorkItemFullyExpanded
{
class Program
{
static void Main(string[] args)
{
GetWorkItemFullyExpanded();
}
public static WorkItem GetWorkItemFullyExpanded()
{
int id = xx;
var myCredentials = new VssClientCredentials();
var connection = new VssConnection(new Uri(@"https://xxxx.visualstudio.com"), myCredentials);
WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient<WorkItemTrackingHttpClient>();
WorkItem workitem = workItemTrackingClient.GetWorkItemAsync(id, expand: WorkItemExpand.Relations).Result;
Console.WriteLine(workitem.Id);
Console.WriteLine("Relations: ");
foreach (var relation in workitem.Relations)
{
if (relation.Rel == "Microsoft.VSTS.Common.TestedBy-Forward")
Console.WriteLine(relation.Url);
}
return workitem;
}
}
}