我在测试管理器中有自动化的测试用例。这个测试用例在不同的构建中执行了几次(它位于几个测试运行中)。我可以通过测试管理器UI查看测试执行的历史记录(Test Manager -> Analyze Test Run -> Open Test Run -> View Result for Testcase -> Result History表)。
如何使用TFS API获取相同的数据?
发布于 2013-05-07 14:51:31
我会这样做:
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;https://stackoverflow.com/questions/16401977
复制相似问题