我怎样才能 link 一个测试用例作为 "tested user story" 和 Microsoft.TeamFoundation API?
How can I link a test case as a "tested user story" with the Microsoft.TeamFoundation API?
我正在用 C# 编写控制台应用程序,使用 Microsoft.TeamFoundation
classes 连接到 Visual Studio Team Foundation Server 2015 本地实例。
我的应用程序需要 create/upload 测试用例并将它们 link 到现有的用户故事。
如果我使用 RelatedLink
class 并将其添加到 ITestCase.Links
属性,当我通过门户网站查看测试用例时,link 出现在所有链接 选项卡,而不是测试用户故事 选项卡。
我如何着手 link 测试用例和故事,以便它们出现在 Tested User Stories 选项卡中?
您需要将Link类型设置为“Tested By
”。
尝试下面的代码示例 link 测试用例 到现有的 用户故事 :(安装 Nuget 包 Microsoft.TeamFoundationServer.ExtendedClient)
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System;
using System.Linq;
namespace AssociateWorkitems
{
class Program
{
static void Main(string[] args)
{
int UserStoryID = 53;
int TestCaseID = 54;
TfsTeamProjectCollection tfs;
tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://ictfs2015:8080/tfs/DefaultCollection"));
tfs.Authenticate();
var workItemStore = new WorkItemStore(tfs);
WorkItem wit = workItemStore.GetWorkItem(UserStoryID);
//Set "Tested By" as the link type
var linkTypes = workItemStore.WorkItemLinkTypes;
WorkItemLinkType testedBy = linkTypes.FirstOrDefault(lt => lt.ForwardEnd.Name == "Tested By");
WorkItemLinkTypeEnd linkTypeEnd = testedBy.ForwardEnd;
//Add the link as related link.
try
{
wit.Links.Add(new RelatedLink(linkTypeEnd, TestCaseID));
wit.Save();
Console.WriteLine(string.Format("Linked TestCase {0} to UserStory {1}", TestCaseID, UserStoryID));
}
catch (Exception ex)
{
// ignore "duplicate link" errors
if (!ex.Message.StartsWith("TF26181"))
Console.WriteLine("ex: " + ex.Message);
}
Console.ReadLine();
}
}
}
我正在用 C# 编写控制台应用程序,使用 Microsoft.TeamFoundation
classes 连接到 Visual Studio Team Foundation Server 2015 本地实例。
我的应用程序需要 create/upload 测试用例并将它们 link 到现有的用户故事。
如果我使用 RelatedLink
class 并将其添加到 ITestCase.Links
属性,当我通过门户网站查看测试用例时,link 出现在所有链接 选项卡,而不是测试用户故事 选项卡。
我如何着手 link 测试用例和故事,以便它们出现在 Tested User Stories 选项卡中?
您需要将Link类型设置为“Tested By
”。
尝试下面的代码示例 link 测试用例 到现有的 用户故事 :(安装 Nuget 包 Microsoft.TeamFoundationServer.ExtendedClient)
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System;
using System.Linq;
namespace AssociateWorkitems
{
class Program
{
static void Main(string[] args)
{
int UserStoryID = 53;
int TestCaseID = 54;
TfsTeamProjectCollection tfs;
tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://ictfs2015:8080/tfs/DefaultCollection"));
tfs.Authenticate();
var workItemStore = new WorkItemStore(tfs);
WorkItem wit = workItemStore.GetWorkItem(UserStoryID);
//Set "Tested By" as the link type
var linkTypes = workItemStore.WorkItemLinkTypes;
WorkItemLinkType testedBy = linkTypes.FirstOrDefault(lt => lt.ForwardEnd.Name == "Tested By");
WorkItemLinkTypeEnd linkTypeEnd = testedBy.ForwardEnd;
//Add the link as related link.
try
{
wit.Links.Add(new RelatedLink(linkTypeEnd, TestCaseID));
wit.Save();
Console.WriteLine(string.Format("Linked TestCase {0} to UserStory {1}", TestCaseID, UserStoryID));
}
catch (Exception ex)
{
// ignore "duplicate link" errors
if (!ex.Message.StartsWith("TF26181"))
Console.WriteLine("ex: " + ex.Message);
}
Console.ReadLine();
}
}
}