Reputation: 3158
It is possible to 'capture' or persist the time it takes per unittest, when running a team build on TFS2010. Ideally saving it to database (like a loadtest can save it to a result store).
Thanks in advance!
Upvotes: 1
Views: 182
Reputation: 3596
If you run Visual Studio unit tests during build, you can choose to publish the test results to the server, then later you can query the test run and results to find out the duration of each test result.
The code to query the test results per build looks like this:
var tcmService = TeamProjectCollection.GetService<ITestManagementService>();
var tcmProject = tcmService.GetTeamProject(TeamProjectName);
ITestRun testRun = tcmProject.TestRuns.ByBuild(BuildUri).First();
ITestCaseResultCollection results = testRun.QueryResults();
foreach (ITestResult result in results) { Console.WriteLine(result.Duration); }
You will need to obtain the team project collection, know the team project name and the build uri. This code assumes that your build has only one published test run, though that sometimes is not true because you can publish other test runs to the same build after it is completed.
Hope this helps.
Upvotes: 1