3
A
回答
-1
您可以使用ITestManagementService
和TestPlan
查询来获得结果具体测试计划
var server = new Uri("http://servername:8080/tfs/collectionname");
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(server);
var service = tfs.GetService<ITestManagementService>();
var testProject = service.GetTeamProject(teamProject);
var plans = testProject.TestPlans.Query("SELECT * FROM TestPlan").Where(tp => tp.Name == YOURTESTPLANNAME).FirstOrDefault();
ITestPlanCollection plans = tfsConnectedTeamProject.TestPlans.Query("Select * From TestPlan");
foreach (ITestPlan plan in plans)
{
if (plan.RootSuite != null && plan.RootSuite.Entries.Count > 0)
{
foreach (ITestSuiteEntry suiteEntry in plan.RootSuite.Entries)
{
var suite = suiteEntry.TestSuite as IStaticTestSuite;
if (suite != null)
{
ITestSuiteEntryCollection suiteentrys = suite.TestCases;
foreach (ITestSuiteEntry testcase in suiteentrys)
{
// Write code to get the test case
}
}
}
}
}
我希望这可以帮到你。
+1
此答案不包含有关如何获得测试用例的结果/结果的内容,仅包含如何遍历测试计划和测试套件。 – Oskar
1
这就是我的做法。
要获得通过,并totalTests我用: ITestRun运行*
run.PassedTests和run.TotalTests
要查看运行状态,我用:
TestRunSTate.Aborted和TestRunState.InProgress
要查看是否失败或不确定我使用:
TestOutcome.Failed或TestOutco me.Inconclusive
首先,我只用ITestRun来简化结果,但我发现他们缺乏任何一种“失败”,我觉得很不安。 所以要正确的数字发送到邮寄给产品负责人聊到TFS API,当我做了以下我的检验报告显示:
var tfs = Connect(optionsModel.CollectionUri);
var tcm = GetService<ITestManagementService>(tfs);
var wis = GetService<WorkItemStore>(tfs);
_testProject = tcm.GetTeamProject(optionsModel.TeamProjectName);
var plan = _testProject.TestPlans.Find(optionsModel.PlanId);
if (plan == null)
throw new Exception("Could not find plan with that id.");
var run = plan.CreateTestRun(true);
var testSuite = _testProject.TestSuites.Find(optionsModel.SuiteId);
if (testSuite == null)
throw new Exception("Could not find suite with that id.");
AddTestCasesBySuite(testSuite, optionsModel.ConfigId, plan, run);
run.Title = optionsModel.Title;
run.Save();
var failedTests = run.QueryResultsByOutcome(TestOutcome.Failed).Count;
var inconclusiveTests = run.QueryResultsByOutcome(TestOutcome.Inconclusive).Count;
希望这有助于 optionsmodel是信息,我从用户参加运行TSTS
相关问题
- 1. 如何使用TFS Rest API获取单元测试结果?
- 2. junit tfs测试结果
- 3. 使用Kiwi获取测试结果
- 4. TFS测试用例 - 获取最新运行结果
- 5. 显示测试结果使用TFS api的表单测试套件
- 6. 从junit测试中获取结果
- 7. 获取最新测试结果
- 8. 使用API的jQuery获取typeform结果
- 9. VS2012使测试结果显示在测试结果窗口
- 10. 回看API:测试用例结果?
- 11. 试图获取JSON结果
- 12. 单元测试Web API控制器:获取错误结果
- 13. 测试panoramio结果
- 14. 获取结果
- 15. 获取结果
- 16. python测试结果与caffe测试结果不一样
- 17. 在TFS上使用CI发布茉莉花测试结果
- 18. 测试人员无法在TFS 2010中发布测试结果
- 19. 获取结果
- 20. 如何从测试运行器获取JUnit测试结果?
- 21. 无法在TFS 2005结果存储中存储加载测试结果
- 22. 如何获取公布的测试结果在Visual Studio 2012
- 23. Jenkins CLI获得测试结果
- 24. 使用Sharepoint维护测试结果
- 25. Android测试 - 使用FEST - isEquals结果
- 26. Android。 Robolectric。测试AccountManager结果
- 27. 后空翻测试结果
- 28. UnityContainer性能测试结果
- 29. Visual Studio测试结果
- 30. 从Erun获得Erlang的测试结果
你可能想看看这个 http://stackoverflow.com/questions/8731854/querying-failed-unit-tests-from-tfs-sdk – Florian
谢谢,但是这不是真的什么我寻找。正如我所说的,我想知道给定的测试用例ID的结果。 – Oskar