문제

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?

도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top