Visual Studio Team Services

Query for Test Results by Tester

TFS’s ITestCaseResultHelper interface (and its TFS API implementation, available via the ITestManagementTeamProject.TestResults property) provides a public API to find one particular ITestCaseResult (based on its TestRunId and TestResultId) and also allows you to perform a query against the TestResults, but unfortunately the later is quite under-documented and it is a bit unclear how to query for ITestCaseResults that were RunBy a particular user.

However, once you know it, it is in fact quite simple. What you need upfront is the Tester’s TeamFoundationIdentity (and obviously an existing ITestManagementTeamProject instance/connection) and based on that, you can do the following:

“[…]

ITestCaseResultCollection testCaseResultsByTester = testManagementTeamProject.TestResults.Query(string.Format("select * from TestResult where RunBy = ’{0}’”, teamFoundationIdentity.TeamFoundationId));

[…]“.

Conveniently, the ITestManagementTeamProject interface provides access to the ITfsIdentityStore via its corresponding .TfsIdentityStore property which allows you to retrieve the corresponding instance by its variety of Getter methods.

This works for both, TFS 2010 and 2012.

Discussion

Comments disabled.