As this previous post explains, before Microsoft Test Manager, there was no real need to know which work items represent bugs or test cases. With VS2010, we introduced the concept of work item categories, which allows us to give a meaning to some of the general work item types we use in the product.
Why do you care about work item categories? Say you want to track information about two different types of bugs – for the purpose of this discussion we’ll use an example of upgrading from TFS 2008 to 2010 (more information about this scenario here). In this scenario, you want to keep your old bugs, but you also want to take advantage of all the new goodies you get with MTM, like filling in your repro steps and system information field when creating or updating a bug. To do this you would create a new bug work item type, leaving the old bugs alone. You can do this easily by using witAdmin. The easiest way to do this is to start with downloading the new bug template, information about how to do this again contained in Chris Patterson’s blog.
When you are done downloading, you’ll want to open the Bug.xml file and make sure you change the name of the work item type, otherwise when importing you’ll overwrite the existing one. You can import your work item by doing:
witadmin importwitd /collection:[tfs collection] /p:[project] /f:[filename].xml
You now have two different work item types and can create & query information about both separately from VS, but to get the best experience in MTM, you need to add the newly created bug work item type to the Bug Category. You again use witAdmin, and again, a good starting point is to export the categories:
witadmin exportcategories /collection:[tfs collection] /p:[project] /f:[filename].xml
You can modify this file by adding your work item inside the Bug Category. It will look like this:
<CATEGORY refname=”Microsoft.BugCategory” name=”Bug Category”>
Notice that one of the work item types has a tag DEFAULTWORKITEMTYPE while the other one has WORKITEMTYPE, this is used to specify the type of bug you want to create when doing New inside of MTLM’s Verify Bugs activity, or from the test runner, which in this case you want to change to the new bug type, so people can create bugs with all the rich information pre-filled.
Save and upload by doing:
witadmin importcategories /collection:[tfs collection] /p:[project] /f:[filename].xml
You will now see both types of bugs seamlessly in MTM wherever queries for bugs are used!
All of this work item categories and custom work item templates has some implications on how you write queries. I’ll have more on that on a later post.