简体   繁体   English

如何在测试用例中更改测试器(TFS API)

[英]how to change tester in test case (TFS API)

I'm trying to change tester of the test case in tfs api 我正在尝试在tfs api中更改测试用例的测试器

in test-case manager i see this testers: https://gyazo.com/03adc434225c4c5541f602bc954feaed 在测试用例管理器中,我看到了这个测试人员: https : //gyazo.com/03adc434225c4c5541f602bc954feaed

i try to create and add TestPointAssignment with this tester: 我尝试使用此测试器创建并添加TestPointAssignment:

IdAndName idAndName = new IdAndName(testSuite.Id, testSuite.Title);
var assignment = testSuite.CreateTestPointAssignment(testCase.Id, idAndName, Tester);
testSuite.AssignTestPoints(new List<ITestPointAssignment>() { assignment });

but nothing changes and remains the same tester. 但没有任何变化,并且保持不变。

how can i change tester in test-case with tfs api? 如何使用tfs api更改测试用例中的测试器?

To change a Tester of a Test Case using TFS API, you could try the following code snippet: 要使用TFS API更改测试用例的测试人员,您可以尝试以下代码段:

string teamProjectName = "TeamProjectName";
TfsTeamProjectCollection tfsCollection = new TfsTeamProjectCollection(new Uri("http://serverName:8080/tfs/MyCollection"));
 ITestManagementService testService = tfsCollection.GetService<ITestManagementService>();
ITestManagementTeamProject teamProject = testService.GetTeamProject(teamProjectName);
//get test point of a test case
ITestPlan tplan = teamProject.TestPlans.Find(testplanid);
ITestPoint point = tplan.QueryTestPoints("SELECT * FROM TestPoint WHERE TestCaseID = Testcaseid").FirstOrDefault();

IIdentityManagementService ims = tfsCollection.GetService<IIdentityManagementService>();
TeamFoundationIdentity tester = ims.ReadIdentity(IdentitySearchFactor.DisplayName, "Mike", MembershipQuery.Direct, ReadIdentityOptions.None);
//change tester for testcase
point.AssignedTo = tester;
point.Save();

I believe your issue is with idAndName. 我相信您的问题是与idAndName有关。

CreateTestPointAssignment expects a list of ITestPointAssignment objects, where each object contains: CreateTestPointAssignment需要ITestPointAssignment对象的列表,其中每个对象包含:

  • The Test Case Id 测试用例ID
  • The Configuration 配置
  • The TeamFoundationIdentity (user) TeamFoundationIdentity(用户)

I believe it's failing because you're specifying the suite id and name, not a configuration id and name. 我相信它失败了,因为您指定的是套件ID和名称,而不是配置ID和名称。

As you're probably aware, each tester gets assigned a Test Point , which is the intersection of a test case and a configuration. 您可能已经知道,每个测试人员都被分配了一个Test Point ,它是测试用例和配置的交集。 In MTM, you can see your configurations in Organize -> Test Configuration Manager . 在MTM中,您可以在Organize- > Test Configuration Manager中查看您的配置。 You'll see the ID and Name there, though in code, you'll probably want to query that list through the suite's DefaultConfigurations property. 您将在此处看到ID和Name,尽管在代码中,您可能想通过套件的DefaultConfigurations属性查询该列表。 (Note that if it's empty, it means it's inheriting configurations from its parent or ancestor, and you may have to get the values from there.) (请注意,如果为空,则表示它是从其父级或祖先继承配置,并且您可能必须从那里获取值。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM