Click here to Skip to main content
11,797,355 members (75,601 online)
Click here to Skip to main content

Tagged as

TFS API Part 28 - Test Suite Hierarchy Builder

, 30 Jul 2010 Ms-PL 14.1K 5
Rate this:
Please Sign up or sign in to vote.
Test Suite Hierarchy Builder

In my previous post regarding TFS API TFS API Part 27 – Test Plans, Test Suites, Test Cases Mapping, I showed how to create and obtain Test Plans, Test Suite and Test Cases objects.

As part of Quality Center to TFS 2010 Migration Tool, I’m translating Quality Center hierarchy into Areas in TFS 2010.

As you can see from the following pictures, the QC hierarchy(middle picture) looks the same as TFS Areas (left picture) but it does not feel the same…

Feels the same? When using QC, you can navigate using the Tree View and drill down to the Test Suite (Folder) you want, to accomplish those actions in TFS you will have to write a Query and each time change the query values, Ammm… it’s not a good solution –
But using Microsoft Test Manager, you can create Test Suites and Requirements with the same hierarchy as QC (right picture).


In order to create those hierarchies quickly in TFS, I built a tool just for that. This tool uses the following articles to complete this task:

The tool is very simple – Connect to TFS 2010, Create or Select Test Plan, Select Areas (One or more) and click start.

This action will take couple of minutes and in the end you will have a full hierarchy in MTM based on the structure of the Areas in your project and the Test Cases assigned under each Area.


The result will be inside the Test Plan you picked before and all the Test Suite will be based on the Area Paths in the current Team Project.

Under each Test Suite, you should see the related Test Cases.


Download Tool

Code Example

Download source code

/// <span class="code-SummaryComment"><summary>

TestSuiteHelper contains a couple of simple actions like AddTests - that perform a Query in TFS to find all Test Cases under specific area path, also FindSuite as a recursive search under each suite (Recursive search because Suite doesn't have unique names so this should be individual search for each Suite).

public class TestSuiteHelper 
    private ITestManagementTeamProject _testproject; 
    private Project _project; 

    public TestSuiteHelper(ITestManagementTeamProject TestManagementTeamProject, 
	Project project) 
        this._testproject = TestManagementTeamProject; 
        this._project = project; 

    public void AddTests(IStaticTestSuite suite, string area) 
        IEnumerable<ITestCase> testcases = 
		("Select * from [WorkItems] where [System.AreaPath] = 
		\"{0}\\{1}\"", _project.Name, area)); 

        foreach (ITestCase testcase in testcases) 

    public IStaticTestSuite FindSuite(ITestSuiteEntryCollection collection, string title)
        foreach (ITestSuiteEntry entry in collection) 
            IStaticTestSuite suite = entry.TestSuite as IStaticTestSuite; 

            if (suite != null) 
                if (suite.Title == title) 
                    return suite; 
                else if (suite.Entries.Count > 0) 
                    FindSuite(suite.Entries, title); 
        return _testproject.TestSuites.CreateStatic(); 


This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


About the Author

Shai Raiten
Architect Sela
Israel Israel
Shai Raiten is VS ALM MVP, currently working for Sela Group as a ALM senior consultant and trainer specializes in Microsoft technologies especially Team System and .NET technology. He is currently consulting in various enterprises in Israel, planning and analysis Load and performance problems using Team System, building Team System customizations and adjusts ALM processes for enterprises. Shai is known as one of the top Team System experts in Israel. He conducts lectures and workshops for developers\QA and enterprises who want to specialize in Team System.

My Blog:

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151002.1 | Last Updated 31 Jul 2010
Article Copyright 2010 by Shai Raiten
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid