简体   繁体   中英

how to change tester in test case (TFS API)

I'm trying to change tester of the test case in tfs api

in test-case manager i see this testers: https://gyazo.com/03adc434225c4c5541f602bc954feaed

i try to create and add TestPointAssignment with this tester:

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?

To change a Tester of a Test Case using TFS API, you could try the following code snippet:

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.

CreateTestPointAssignment expects a list of ITestPointAssignment objects, where each object contains:

  • The Test Case Id
  • The Configuration
  • The TeamFoundationIdentity (user)

I believe it's failing because you're specifying the suite id and name, not a configuration id and name.

As you're probably aware, each tester gets assigned a Test Point , which is the intersection of a test case and a configuration. In MTM, you can see your configurations in 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. (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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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