1

We have a legacy of thousands of manual Test Cases created in Microsoft Test Manager in our on premises TFS 2013.

We are trying to move them to VSTS and it proved to be difficult.


I.

As far as I can see at the moment there is no official migration tool from Microsoft, although they are working on one for full data migration


II.

We've tried a few third party tools:

  • OpsHub - free version has a 2500 limit which we exceed, and we can't justify $5,000 cost of commercial version
  • TFS Integration Tools - doesn't seem to migrate Test Cases at all (documentation by the link confirms this)
  • MTMCopyTool - doesn't seem to migrated Steps of Test Cases, leaves them empty

III.

We've also tried exporting-importing TFS\VSTS Query in Excel. Which seems to export Steps too but all of them concatenated in one field, no even new line character between them, which makes it quite messy.


IV.

We've also tried using third part tool to export-import via Excel:

Ivan
  • 9,089
  • 4
  • 61
  • 74

1 Answers1

3

For a one-shot migration I can suggest a couple of options:

  1. From the test hub in your on-premises web access, create a test plan including all the test cases and then switch to the grid view in the main pane. There you can select and copy all test cases (including steps, expected results and other test case fields) and paste them into the equivalent view in the VSTS project.

  2. Create a powershell script that gets all the test cases from your on-premises TFS and copies them into VSTS. Below you can find a snippet. Caveat: I have not tested it extensively, so usual disclaimers apply. Please add additional fields you may want to copy.

    $VerbosePreference = "Continue"
    
    $tfsSource="the collection url that you want to copy form (eg. http://yourserver/tfs/yourcollection)";
    $tpSource="the team project containing the test cases you want to copy form";
    
    $tfsDest="the collection url that you want to copy to (eg. https://youraccount.visualstudio.com/DefaultCollection");
    $tpDest="the team project containing the test cases you want to copy to";
    
    
    [Reflection.Assembly]::LoadWithPartialName(‘Microsoft.TeamFoundation.Client’)
    [Reflection.Assembly]::LoadWithPartialName(‘Microsoft.TeamFoundation.TestManagement.Client’)
    [Reflection.Assembly]::LoadFile("C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\Newtonsoft.Json.dll")
    
    $sourceTpc = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsSource)
    $sourceTcm = $sourceTpc.GetService([Microsoft.TeamFoundation.TestManagement.Client.ITestManagementService])
    $sourceProject = $sourceTcm.GetTeamProject($tpSource);
    $sourceTestCases = $sourceProject.TestCases.Query(“SELECT * FROM WorkItem”);
    
    $destTpc= [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsDest)
    $destTcm = $destTpc.GetService([Microsoft.TeamFoundation.TestManagement.Client.ITestManagementService])
    $destProject = $destTcm.GetTeamProject($tpDest);
    
    
    foreach ($tc in $sourceTestCases)
    {
        Write-Verbose ("Copying Test Case {0} - {1}" -f $tc.Id, $tc.Title)
        $destTestCase= $destProject.TestCases.Create();
        $destTestCase.Title = $tc.Title;
        $destTestCase.Priority = $tc.Priority;
    
        foreach ($step in $tc.Actions)
        {
            $destStep= $destTestCase.CreateTestStep();
    
            $destStep.Title= $step.Title
            $destStep.TestStepType= $step.TestStepType
            $destStep.Description= $step.Description
            $destStep.ExpectedResult=  $step.ExpectedResult;
            $destTestCase.Actions.Add($destStep);
        }
        $destTestCase.Save();
    }
    
aforcina
  • 81
  • 3
  • Thanks for ideas. Tried 1st and it seems to limit Grid to 20 test cases only, is there any way to show all? – Ivan Oct 04 '16 at 12:03
  • 1
    I managed to copy/paste 25, so there could be a limit on the overall clipboard size. I have found no documentation on this limit, it looks like an internal constraint. So if you go down this route you should do multiple copy/paste... I feel your pain... – aforcina Oct 04 '16 at 16:50
  • 1
    I have added the powershell code snippet in the answer above. – aforcina Oct 04 '16 at 21:36
  • Got the script working, still playing with it. Just a quick question - is there any need in Newtonsoft.Json.dll that you load? – Ivan Oct 05 '16 at 18:44
  • Yes, apparently NewtonSoft.Json is needed by the new TFS APIs, because the Save method will fail if you don't load it. I've tested my script migrating from an on premises 2015.3 TFS to my personal VSTS account. – aforcina Oct 06 '16 at 10:17
  • Interestingly it worked for me without importing Newtonsoft.Json.dll – Ivan Oct 06 '16 at 13:41
  • Great! Please mark as answer my post if it helped you. Thanks. – aforcina Oct 07 '16 at 18:24
  • Thank you. Working on it to migrate with full hierarchy of Test Plans and Test Suites. – Ivan Oct 08 '16 at 07:00