Domanda

I have automated testcase in Test Manager. This testcase was executed several times in different builds (It is situated in several test runs). I can see history of test execution through Test Manager UI (Test Manager -> Analyze Test Runs -> Open Test Run -> View Results for Testcase -> Result History table).

How to get same data using TFS API?

È stato utile?

Soluzione

I would do it this way:

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.TestManagement.Client;

var tfsCollection = new TfsTeamProjectCollection(
                new Uri(@"http://<yourTFS>:8080/tfs/<your collection>"),
                new System.Net.NetworkCredential(<user who can access to TFS>,<password>));
tfsCollection.EnsureAuthenticated();

ITestManagementService testManagementService = tfsCollection.GetService<ITestManagementService>();

var testRuns = testManagementService.QueryTestRuns("SELECT * FROM TestRun WHERE TestRun.TestPlanId=<your test plan ID>");

IEnumerable<ITestCaseResult> testResultHistoryYouWant = from testRun in testRuns
                                from testResult in testRun.QueryResults()
                                where testResult.TestCaseId == <your test case ID>
                                select testResult;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top