How can I configure MTM to use my custom bug / test case type?
Note: Cross posted from Rubel's Blog.
Permalink
How can I configure MTM to use my custom bug / test case type?
I got this Q on my previous blog and thought of posting a separate post on it as it's a bit tricky to do it and hence other folks may need this info.
In Microsoft Test Manager (MLM), we don’t provide any UI way to set a particular work item type as default work item type for a category. Basically, if I’ve added a new bug type say “CustomBug” to TFS and want MTM to refer to that type always while opening a new bug etc then there is no UI way to achieve it.
But yes, you can do it through witadmin using importcategories / exportcategories command.
First you need to exports the XML definition of categories defined on the Team Foundation Server by using exportcategories command e.g.
The following command exports the work item type categories defined for the AdventureWorks project to the Categories XML file:
C:\Program Files\Microsoft Visual Studio 10.0\VC>witadmin exportcategories /collection:"https://AdventureWorksServer:8080/AWTeam/Collection1”
/p:AdventureWorks /f:"Categories.xml"
Categories.xml will look this:
<?xml version="1.0" encoding="utf-8"?>
<cat:CATEGORIES xmlns:cat="https://schemas.microsoft.com/VisualStudio/2008/workitemtracking/categories">
<CATEGORY refname="Microsoft.BugCategory" name="Bug Category">
<DEFAULTWORKITEMTYPE name="Bug" />
</CATEGORY>
<CATEGORY refname="Microsoft.RequirementCategory" name="Requirement Category">
<DEFAULTWORKITEMTYPE name="User Story" />
</CATEGORY>
<CATEGORY refname="Microsoft.SharedStepCategory" name="Shared Step Category">
<DEFAULTWORKITEMTYPE name="Shared Steps" />
</CATEGORY>
<CATEGORY refname="Microsoft.TestCaseCategory" name="Test Case Category">
<DEFAULTWORKITEMTYPE name="Test Case" />
</CATEGORY>
</cat:CATEGORIES>
As you can see that there is default work item type for each category like Bug, Test Case, Shared Step.
You just need to modify the xml file so as to point DEFAULTWORKITEMTYPE of required category to yours newly created work item type. E.g. If I want to use work item type CustomBug as default work item type for Bug category then my modified XML will look like this:
<?xml version="1.0" encoding="utf-8"?>
<cat:CATEGORIES xmlns:cat="https://schemas.microsoft.com/VisualStudio/2008/workitemtracking/categories">
<CATEGORY refname="Microsoft.BugCategory" name="Bug Category">
<DEFAULTWORKITEMTYPE name="CustomBug" />
</CATEGORY>
<CATEGORY refname="Microsoft.RequirementCategory" name="Requirement Category">
<DEFAULTWORKITEMTYPE name="User Story" />
</CATEGORY>
<CATEGORY refname="Microsoft.SharedStepCategory" name="Shared Step Category">
<DEFAULTWORKITEMTYPE name="Shared Steps" />
</CATEGORY>
<CATEGORY refname="Microsoft.TestCaseCategory" name="Test Case Category">
<DEFAULTWORKITEMTYPE name="Test Case" />
</CATEGORY>
</cat:CATEGORIES>
After that you just need to import this XML back into team project of TFS using importcategories. e.g. The following example imports categories from the myCategories XML file to the AdventureWorks project:
C:\Program Files\Microsoft Visual Studio 10.0\VC>witadmin importcategories /collection:"https://AdventureWorksServer:8080/AWTeam/Collection1”
/p:AdventureWorks /f:"Categories.xml"
Now if you open any bug in Test Runner / MTM then it will open your CustomBug work item type form instead of default bug form. Similarly you can do required changes to use customized Test Case / any other work item.
Required Permissions
For the team project where the work item types are defined, you must have the following permissions set:
· To export categories of work item types, you must be a member of the Readers group or have your View work items in this node permission set to Allow
· To import categories of work item types, you must be a member of the Team Foundation Administrators security group or the Project Administrators security group.
For more details on TFS permissions check hereNote: Cross posted from Rubel's Blog.
Permalink
Comments
Anonymous
February 20, 2012
Hi I've done the as suggesated but at the import phase I've got the following error: Could u help? TF237059: The import of the category definition failed. In the type definition, category Test Case Category refers to a work item type that does not exist Test Case. Operation failed.Anonymous
February 20, 2012
I've found the solution, i had to import the test case worker item type from another projectAnonymous
December 17, 2013
Hi, i'm facing an issue. I created a WIT using process editor and it created the WIT successfully. Now the problem is that, the new work item is showing in the VS WIT list but when i go to Microsoft test manager, it doesn't show in the list there. Also there are some wort item types that does not show in the MTM but they do show in VS for the same project. Can you please help me how can i make those WIT available in MTM as well.