Posts

Showing posts from August, 2013

TFS API: How to get latest test result for a test case

We can retrieve test results for particular test case using TFS API. That's straight forward and there are in build methods. I find people asking for how they can retrieve latest test result for particular test case and I got it solved so thought of sharing here. below code snippet will illustrate how to - 1. Connect to TFS Server/Collection/team project Uri tfsUri = new Uri( "http://servername:8080/tfs/collectionname" ); teamProjectCollection = new TfsTeamProjectCollection(tfsUri);   iTestManagementService = teamProjectCollection.GetService<ITestManagementService>(); tfsConnectedTeamProject = iTestManagementService.GetTeamProject( "Team Project Name" );   2. Once connected to TFS server, call APIs to get test results for any particular test case. Below line of code will get all results associated with passed test case Id and this returned list is not sorted var testResults = tfsConnectedTeamProject.TestResults.ByTestId(52737); 3. W