使用TFS API显示测试结果表单测试套件 [英] Show Test result Form test suites using TFS api

查看:166
本文介绍了使用TFS API显示测试结果表单测试套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与一个学校项目合作,该项目将分析公司的缺陷数据库. 他们正在使用Microsoft Foundation Server(TFS). 我是TFS和TFS api的新手.

I am working with a school project where I am going to analyse a companies defect database. They are using Microsoft Foundation Server (TFS). I am all new to TFS and the TFS api.

使用TFS客户端对象模型从TFS获取正确的数据时遇到一些问题 . 我可以检索所有测试计划,它们各自的测试套件以及特定测试套件使用的每个测试用例,但是当我想查看在哪个测试套件中我有一个测试用例的特定测试结果时,问题就来了.由于多个套件可以使用相同的测试用例,因此我看不到结果来自哪个套件.

I have some problem in getting the right data from TFS using the TFS Client Object Model . I can retrieve all Test Plans, their respective test suites and every test case that a specific test suite uses, but the problem comes when I want to see in which test suite I have a specific test result from a test case. Since more than one the suite can use the same test cases, I cant see in which suite the result came from.

我正在通过这种方式从套件中获取测试用例:

I am doing this way in getting test cases from suites:

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);
    }
}

所以我的问题是,如何查看用于执行测试的测试套件?

So my question is, how can I see the Test Suite which was used to execute the test?

推荐答案

看看下面的代码片段.
它显示了如何使用测试点ID 获取特定 Test Suite 测试结果.
您可以使用类似的方法来实现您的目标.

Have a look at following code snippet.
It shows you how to get Test Results for a specific Test Suite using Test Points Ids.
You can use similar approach to achieve your goal.

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进行测试

This blog post will help you when creating queries: WIQL for Test

这篇关于使用TFS API显示测试结果表单测试套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆