【问题标题】:C# to add test case or user story under a team in a projectC# 在项目中的团队下添加测试用例或用户故事
【发布时间】:2016-03-08 15:36:52
【问题描述】:

我想使用 C# 访问 TFS 项目并创建一个测试用例。下面是项目结构

网址:http://localhost:8080/tfs/test

项目:project1

团队名称:team1

在此处添加测试用例或工作项

我能够连接到项目并在那里添加一个工作项,但是我如何连接到项目中的特定团队(在本例中是 team1)并添加一个测试用例或工作项

这是我的示例代码

namespace ConsoleApplication1
{
class Program
{
    static void Main(string[] args)
    {
        Uri collectionUri = (args.Length < 1) ?
                     new Uri("http://localhost:8080/tfs/test") : new Uri(args[0]);
        System.Console.WriteLine(collectionUri);
        TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
        WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
        Project teamProject = workItemStore.Projects["project1"];
        WorkItemType workItemType = teamProject.WorkItemTypes["User Story"];


        // Create the work item. 
        WorkItem userStory = new WorkItem(workItemType)
        {
            // The title is generally the only required field that doesn’t have a default value. 
            // You must set it, or you can’t save the work item. If you’re working with another
            // type of work item, there may be other fields that you’ll have to set.
            Title = "test through code",
            Description =
                "this is an automation user story genrated"
        };

        // Save the new user story. 
        userStory.Save();
    }
}
}

【问题讨论】:

    标签: tfs tfsbuild azure-devops team-explorer


    【解决方案1】:

    我们使用分类字段(区域和迭代)来定义 TFS 中的“团队”。您没有指定如何定义“团队”,但假设您使用分类字段,您可以按如下方式设置迭代字段:

        WorkItem userStory = new WorkItem(workItemType)
        {
            // The title is generally the only required field that doesn’t have a default value. 
            // You must set it, or you can’t save the work item. If you’re working with another
            // type of work item, there may be other fields that you’ll have to set.
            Title = "test through code",
            Description =
                "this is an automation user story genrated",
            IterationPath = FormatPath(commonservice.GetNode(newIterationPath).Path, "Iteration", "MyTeamProject");
        };
    

    【讨论】:

      猜你喜欢
      • 2017-11-11
      • 2012-06-11
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 2019-04-11
      • 2018-09-13
      • 2017-08-08
      • 1970-01-01
      相关资源
      最近更新 更多