我正在参与一个学校项目,我将在其中分析公司的缺陷数据库。
他们正在使用 Microsoft Foundation Server (TFS)。
我对 TFS 和 TFS api 很陌生。
我在使用 TFS 客户端对象模型从 TFS 获取正确数据时遇到一些问题
。
我可以检索所有测试计划、它们各自的测试套件以及特定测试套件使用的每个测试用例,但是当我想查看哪个测试套件中有测试用例的特定测试结果时,问题就出现了。由于多个套件可以使用相同的测试用例,因此我无法看到结果来自哪个套件。
我正在这样做从套件中获取测试用例:
foreach (ITestSuiteEntry testcase in suiteEntrys)
{
Console.WriteLine("\t \t Test Case: {0}", testcase.Title+", "+"Test case priority: "+ testcase.TestCase.Priority+"Test case Id: "+testcase.TestCase.Id);
//Console.Write(", Test Case: {0}", testcase.ToString());
//get each test result:
getTestResult(testcase,proj);
}
private void getTestResult(ITestSuiteEntry testcase, ITestManagementTeamProject proj)
{
var testResults = proj.TestResults.ByTestId(testcase.TestCase.Id);
foreach (ITestCaseResult result in testResults)
{
Console.WriteLine("\t \t \t"+result.DateCreated+","+result.Outcome);
}
}
所以我的问题是,如何查看用于执行测试的测试套件?
看看下面的代码片段。
它向您展示了如何获得检测结果对于特定的测试套件 using 测试点 ID.
您可以使用类似的方法来实现您的目标。
var tfsCollection = new TfsTeamProjectCollection(
new Uri(tfsUrl),
new System.Net.NetworkCredential(<user>, <password>));
tfsCollection.EnsureAuthenticated();
var testManagementService = tfsCollection.GetService<ITestManagementService>();
var teamProject = testManagementService.GetTeamProject(projectName);
var testPlan = teamProject.TestPlans.Find(testPlanId);
// Get all Test Cases belonging to a particular Test Suite.
// (If you are using several Test Configurations and want to take only one of them into account,
// you will have to add 'AND ConfigurationId = <your Test Configuration Id>' to the WHERE clause.)
string queryForTestPointsForSpecificTestSuite = string.Format("SELECT * FROM TestPoint WHERE SuiteId = {0}", suiteId );
var testPoints = testPlan.QueryTestPoints(queryForTestPointsForSpecificTestSuite);
// We are going to use these ids when analyzing Test Results
List<int> testPointsIds = (from testPoint in testPoints select testPoint.Id).ToList();
var testResults = teamProject.TestResults.ByTestId(testCaseId);
var testResultsForSpecificTestSuite = testResults.Where(testResult => testPointsIds.Contains(testResult.TestPointId));
这篇博文将在创建查询时为您提供帮助:测试用 WIQL
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)