TestProject Forum
Powered by leading experts in the test automation community

TFS API get full path (folder) of each workitem in assembly

I have a WorkItemCollection of work items (test cases). I am trying to find the path of each work item via .net code (TFS API). The folder / subfolder for each item in the solution-assembly tree. Is it possible to get? is it stored somewhere within each item’s object ?

I don’t think it’s possible to get that data from the item object.

But you could map each test case to it’s relevant hierarchy by setting the default area of each work item with its respective path.

Alternatively, you could give each work item different tags representing your path, and then retrieve those tags via TFS API code.

 public static string[] GetTagsForWorkItem(Uri tfsUri, int workItemId) 
            // get a reference to the team project collection 
            using (var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri)) 
                // get a reference to the work item tracking service 
                var workItemStore = projectCollection.GetService<WorkItemStore>();

                // and get the work item 
                var wi = workItemStore.GetWorkItem(workItemId); 
                return wi.Tags.Split(';');