C# 如何使用Visual C控制台创建和访问Team Foundation服务器中的测试用例
我正在与VSC合作,操纵测试用例,创建项目,以及任何有利于我在TFS中测试的东西。然而,没有任何可靠的例子。微软开发者网站上的API对我没有帮助(可能是因为我缺乏在VS中编码的经验),但我越来越沮丧。我取得的任何进步都需要几天的时间(…真是一帆风顺)。有人可以指导我使用一个统一的资源来使用Team Foundation Server对象模型以编程方式实现特性:网站、书籍等等。谢谢下面是创建默认集合/项目并使用C#在VSO TFS中编写测试用例的非常简单的代码(它仍然失败):C# 如何使用Visual C控制台创建和访问Team Foundation服务器中的测试用例,c#,tfs,C#,Tfs,我正在与VSC合作,操纵测试用例,创建项目,以及任何有利于我在TFS中测试的东西。然而,没有任何可靠的例子。微软开发者网站上的API对我没有帮助(可能是因为我缺乏在VS中编码的经验),但我越来越沮丧。我取得的任何进步都需要几天的时间(…真是一帆风顺)。有人可以指导我使用一个统一的资源来使用Team Foundation Server对象模型以编程方式实现特性:网站、书籍等等。谢谢下面是创建默认集合/项目并使用C#在VSO TFS中编写测试用例的非常简单的代码(它仍然失败): 使用系统; 使用Sy
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用Microsoft.TeamFoundation.Client;
使用Microsoft.TeamFoundation.TestManagement.Client;
使用Microsoft.TeamFoundation.WorkItemTracking.Client;
名称空间myProject
{
班级计划
{
静态void Main(字符串[]参数)
{
字符串serverurl=”http://localhost:8080/tfs";
字符串project=“Beta1”;
ITestManagementTeamProject proj=GetProject(serverurl,project);
ITestCase tc=proj.TestCases.Create();
tc.Title=“测试”;
tc.Save();
WriteLine(“TC:{0}”,TC.Id);
}
静态ITestManagementTeamProject GetProject(字符串serverUrl,
字符串项目)
{
TfsTeamProjectCollection tfs=新的TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullQualifiedUriForName(serverUrl));
ITestManagementService tms=tfs.GetService();
返回tms.GetTeamProject(project);
}
}
}
代码片段中的serverul“”表示您正在处理内部部署TFS。但是在您的描述中,您希望在VisualStudioOnline中创建一个测试用例工作项
有关Visual Studio Online api,您可以在以下网站上参考Visual Studio Online REST api:
要以编程方式处理本地TFS,您可以参考以下博客:
对于在线参考,我衷心推荐Shai Raiten的博客:你可能还会发现我的一些帖子很有用:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.TestManagement.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace myProject
{
class Program
{
static void Main(string[] args)
{
string serverurl = "http://localhost:8080/tfs";
string project = "Beta1";
ITestManagementTeamProject proj = GetProject(serverurl, project);
ITestCase tc = proj.TestCases.Create();
tc.Title = "Test";
tc.Save();
Console.WriteLine("TC: {0}", tc.Id);
}
static ITestManagementTeamProject GetProject(string serverUrl,
string project)
{
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullQualifiedUriForName(serverUrl));
ITestManagementService tms = tfs.GetService<ITestManagementService>();
return tms.GetTeamProject(project);
}
}
}