Click here to Skip to main content
12,883,460 members (38,183 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

5.9K views
1 bookmarked
Posted 13 Dec 2011

TFS 2011 API – How to Get Exploratory Testing And Feedback Manager Session Information Programmatically

, 13 Dec 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
How to use the TFS 2011 API to get the Exploratory Testing & Feedback Manager session information programmatically

In this blog post, I’ll show you how to use the TFS 2011 API to get the Exploratory Testing & Feedback Manager session information programmatically.

Introduction

TFS 2011 includes Exploratory Testing and Feedback Manager, the first empowers the testers to explore the application and second empowers the stake holders to explore the application. This rhymes a bit… that’s because… under the hood, both use the same infrastructure to drive and store the session information. If you try to run both at the same time on a machine, you will run into the following warning message.

image

Note both Feedback manager and Exploratory testing store the results in the table [Tfs_DefaultCollection].[dbo].[tbl_Session] in the TFS operational database.

image

Note: Any direct interaction (including select statements) against the TFS operational databases is strongly discouraged by the Product Team. All such interactions should be done through the TFS SDK.

How to Get the Exploratory Session and Feedback Manager Session Programmatically using TFS API…

Download the working demo… or follow the steps below:

image

  1. Add references:
    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.TestManagement.Client;
  2. Connect to TFS and select a Team Project:
    private TfsTeamProjectCollection _tfs;
    private string _selectedTeamProject;
    
    private void ConnectToTfsAndPickAProject()
    {
         // Connect to TFS and pick team project
         TeamProjectPicker tfsPP = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);
         tfsPP.ShowDialog();
         this._tfs = tfsPP.SelectedTeamProjectCollection;
         this._selectedTeamProject = tfsPP.SelectedProjects[0].Name;
     }
  3. Get access to Session Helper:
    // Get the Session Helper 
    var tms = _tfs.GetService<ITestManagementService>();
    var sessionHelper = tms.GetTeamProject(_selectedTeamProject).SessionHelper;
  4. Now use the session helper to query for the session Information. For example, in the snippet below, I am simply getting all sessions:
    // Get Session by Query
    var sessionByQuery = sessionHelper.Query("Select * from Session");
    dataGridView1.DataSource = sessionByQuery.ToList();
    dataGridView1.AutoGenerateColumns = true;
    // I could write a more specific query
    var sessionQueryExample = sessionHelper.Query("Select * from Session where TestPlanId =3");

    BONUS – Go One Step Further...

  5. Get Session Information by Link Id: In the Links section in a Bug, you can see the test results attachment, you can use the ‘FindByLinkId’ method to get the details of that session programmatically.
    // Get Session details for a bug raised during session testing
                // 1. Get the bug 
                var qBug = @"SELECT 
                                [System.Id], 
                                [System.Links.LinkType], 
                                [System.WorkItemType], 
                                [System.Title], 
                                [System.State], 
                                [Custom.TestingTour],
                                [Microsoft.VSTS.Common.Priority] 
                            FROM WorkItems 
                            WHERE [System.TeamProject] = '@project'  
                                AND  [System.WorkItemType] = 'Bug'"
                    .Replace("@project", _selectedTeamProject);
    
                // Get the Wi Store service
                var wis = _tfs.GetService<WorkItemStore>();
    
                var queryBug = new Query(wis, qBug);
                var bugs = queryBug.RunQuery();
    
                // 2. Get the Uri of the session from the bug
                foreach (WorkItem bug in bugs)
                {
                    foreach (Link l in bug.Links)
                    {
                        if (l.ArtifactLinkType != null && l.ArtifactLinkType.Name == "Test Result")
                        {
                            // 3. Get Session Information By URI
                            var sessionByUri = 
                            sessionHelper.FindByLink(new Uri(((ExternalLink)l).LinkedArtifactUri));
                        }
                    }
                }

You might also enjoy reading => How to customize Process Template In TFS 2011.

Hope you enjoyed this post! Remember to subscribe to http://feeds.feedburner.com/TarunArora.

Enjoy!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Tarun_Arora
Software Developer (Senior) Avanade
United Kingdom United Kingdom
Solution Developer - C# .NET, ALM

Tarun Arora is a Microsoft Certified professional developer for Enterprise Applications. He has over 5 years of experience developing 'Energy Trading & Risk Management' solutions using Microsoft Technologies. Tarun has great passion for technology and travel (not necessarily in the same order)!

You may also be interested in...

Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170422.1 | Last Updated 14 Dec 2011
Article Copyright 2011 by Tarun_Arora
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid