The Results of a Test Run can be obtained by using TFS 2010 API
You first need to add a reference to Microsoft.TeamFoundation.Client.dll and Microsoft.TeamFoundation.TestManagement.Client.dll
These dll can be found under C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies
The below code describes how to obtain Failed test cases of a Test Run
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(http://%3cserver%3e:8080/tfs/%3Ccollection%3E));
ITestManagementService testManagement = (ITestManagementService)tfs.GetService(typeof(ITestManagementService));
ITestManagementTeamProject testManagementTeamProject = testManagement.GetTeamProject(teamProject);
// _testRunID is the Run ID of the Test Run
ITestRun testRun = testManagementTeamProject.TestRuns.Find(_testRunID);
// Get Failed Test Cases
ITestCaseResultCollection testcases = testRun.QueryResultsByOutcome(TestOutcome.Failed);
foreach (ITestCaseResult testcase in testcases)
{
// Print Test Case Details
Console.WriteLine("TestCase ID: " + testcase.TestCaseId);
Console.WriteLine("TestCase Title: " + testcase.TestCaseTitle);
Console.WriteLine("Error Message: " + testcase.ErrorMessage);
}
Similarly test cases which are Passed, Aborted, etc. can be found out by passing TestOutcome.Passed , TestOutcome.Aborted, etc
TejasJ edited Revision 2. Comment: tags edit.
I have an ordered test with 13 cases.When i use ITestCaseResultCollection testcases = testRun.QueryResultsByOutcome(TestOutcome.Failed); i am getting the result of ordered Test.But is there any way to get the test Case result of the test cases within the ordered test
As far as I know, there is no direct way to get individual test level details of an ordered test.
I get the following error:Error
The type 'System.Collections.Specialized.INotifyCollectionChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I've included a using System.Collection.Specialized, but this doesn't resolve it.
Just in case someone else sees this, I found the problem. I had to include WindowsBase.dll