10 September 2015

The required category ‘Microsoft.TestCaseCategory’ does not exist in team project ‘[projectname]’

When connecting to our TFS 2015 project with Microsoft Test Manager two of our team members were unable to connect, instead receiving:

The required category ‘Microsoft.TestCaseCategory’ does not exist in team project ‘[projectname]’

Googling for solutions I came across http://www.almguide.com/2011/01/the-required-category-microsoft-testcasecategory-does-not-exist-in-team-project-projectname/. I checked on my machine what the state of the categories was using the following statement.

witadmin.exe exportcategories /collection:http://[yourtfsinstance:port]/tfs/[collectionname]

Turns out that they were there and it was a complete list. So far so good. However, running the statement on my colleagues machine (or using his credentials on my machine, which led to the same result): not a single category...only the category element root tag...

In effect this had to be the root cause for the exception message in Test Manager 2015. After connecting to the TFS database and starting a profile and rerunning the export statement, I saw no actual database activity, which led me to think that some caching mechanism was in place. Rebuilding the TFS cache can be done by using the following command:

witadmin rebuildcache /collection:http://[yourtfsinstance:port]/tfs/[collectionname]
The statement finished swiftly probably because our TFS instance is relatively young, you milage may vary as there is a warning upon execution that states:
To avoid server performance issues, you should not run this command during typical operating hours.
After rebuilding the cache everyone was able to connect to the team project as intended! 
Hope this helps someone.