Team Foundation Server Integration Tools – Watch Your Shared Step

One of my clients had recently created a Team Project in TFS 2010, but after a few weeks, decided they wanted to change the name of the Team Project.  Since this is not supported in TFS 2010, we decided to create a new Team Project with the new name and use the Integration Tools to move the work items and source code over.  Being a TFS 2010 to TFS 2010 migration, I expected everything to go smoothly and for the most part it did.  After confirming that everything got migrated correctly, I removed the users permissions from the old Team Project and directed them to use the new one.

After a couple of days, I started to receive reports from a few of the testers that they could not open their Test Cases.  They were getting the following error “TF26198: The work item does not exist or you do not have permissions to access it”.  I was able to open the Test Cases.  They also were unable to open some of the Requirement work items with the same error, but other Requirements they could open.

The problem turned out to be the Shared Steps work items.  Any Test Case that had Shared Steps or any requirement that linked to a Test Case that had Shared Steps could not be opened by the testers.  It turns out that the Integration Tools migrate the Test Cases and the Shared Steps correctly, but the mapping of the Test Cases to the Shared Steps is not.  The Test Cases were still pointing to the Shared Steps work items from the old Team Project.  For example, when opening the Shared Steps from a Test Case in the new Team Project, the work item id of the Shared Steps work item was the one from the old Team Project.  The reason why they could not open the Test Cases or Requirements was because I took their permissions away from the old Team Project.  Once I added their permissions back, they were able to open them.

The solution for me was to map the work item ids from the old Team Project’s Shared Steps to the new Team Project’s Shared Steps work item ids.  I then went through each Test Case and deleted the Shared Steps work items from the Manual Steps and re-added them with the equivalent Shared Steps work item in the new team project.  The other option would have been to go directly into the “WorkItemLongTexts” table of the TFS collection database and change the Shared Step reference in the XML data structure.  This probably would have taken just as long if not longer and would be very risky.  It is never a good idea to change data directly in the TFS databases.  Luckily, they only had around 50 Test Cases, so it took a couple of hours to fix.

I have not tried it yet, but there is the Test Case Migrator plus tool that is supposed to migrate all Test Case related work items over correctly.  It can be found at http://tcmimport.codeplex.com/.