How to migrate MTM Test Cases from TFS 2013 to VSTS? - visual-studio

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:
to export: https://tfstestcaseexporttoexcel.codeplex.com/ - seems to export everything fine, including Steps! Not sure how to import this file though to VSTS
to import: Test Case Migrator Plus just crashes on my machine, though source code is available so maybe I'll try to play with it

For a one-shot migration I can suggest a couple of options:
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.
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();
}

Related

how can i migrate my current tfs 2013 custom work items to 2015 visual studio cloud?

I currently use TFS 2013 with custom work items for bugs, change request, requirements and features. I am wondering if I can migrate them to visual studio cloud 2015? is there a tool within VS or 3rd party that can do this?
If you are meaning the vsts. Possibly duplicate with this question: How to migrate work items from TFS to VS Team Services (VS Online) . There has been perfect answer from jessehouwing, suggest use one of below three ways as he suggested:
Use Excel for import/export - Will work for most work items, you loose attachments and work item links other than parent/child. The
trick is to extract from one Project Collection then copy all fields,
except the ID to an Excel sheet bound to the target project
collection. You will need to fix all Identity fields (works best when
users have the exact same display name on premise as in VSTS) and
you'll have to import once with state new and then past the current
state/reason over the just imported values and sync again. Test
Cases, Plans, Suites and Shared Steps will not be imported with their
relations in tact. The approach would be very similar to this
one.
Use the TFS Integration Tools - Will work for most work item types, though it will loose custom kanban states and tags. Test
cases, Shared steps and their relations will not be imported. This
option will allow you to import import work items and source code
with their relationships in tact.
Use a 3rd party solution - Out of the available options currently OpsHub offers the most complete solution. For test case and
source control link migration you're looking at the commercial
edition, which comes at a steep price. It still has a long list of
known issues and last time I tried it, I ran into numerous
issues which required their support to resolve them. PS: You can aslo try the tool as Dave suggested in the comment: VSTS Sync Migration Tools

How to migrate work items from TFS to Visual Studio Team Services

My team currently works with an on-premises TFS 2012 server. I am migrating everything to Visual Studio Team Services, formerly Visual Studio Online. I am starting with a test project and was able to easily get all the code migrated, but can't figure out how to do the same for the work items.
Are there any good guides out there?
New options as of March 29th 2018:
TFS to VSTS migration - The official import option which will import 1 project collection into 1 VSTS account. It automatically imports everything stored in the backup. At the point of writing this, the TFS must be upgraded to TFS 2018 and some work item template customizations must be removed (there are a few well documented features unavailable on VSTS).
VSTS Sync Migrator - Marting Hinshelwood, the uncrowned king of TFS and VSTS migrations, has built his own little tool that can migrate work items from one server/account to another. It can even do migrations from one Team Project to another and while doing it switch between process templates.
VSTS Work Item Migrator - Microsoft has also open sourced a project that they used internally to migrate work items. It's less powerful, but it was made by Microsoft.
Previous answer:
At the moment there isn't a really good story. Your options are:
Start over - easiest :).
Start over and manually recreate items of value - It's a pain, but it's some teams have done these things in the past. keep the old TFS server available in read-only mode and each time you use a work item in the old system, you manually create it in the new one, set all the fields and upload the attachments. Depending on the number of items it'll take you a few sprints to migrate the most important stuff over.
Wait a while longer - Microsoft is currently working on a full fidelity import option which will allow you to upload a Project Collection and it will be exposed as a new VSTS Account (it's not going to be possible to import a project collection into an existing account).
Use Excel for import/export - Will work for most work items, you loose attachments and work item links other than parent/child. The trick is to extract from one Project Collection then copy all fields, except the ID to an Excel sheet bound to the target project collection. You will need to fix all Identity fields (works best when users have the exact same display name on premise as in VSTS) and you'll have to import once with state new and then past the current state/reason over the just imported values and sync again. Test Cases, Plans, Suites and Shared Steps will not be imported with their relations in tact. The approach would be very similar to this one.
Use the TFS Integration Tools - Will work for most work item types, though it will loose custom kanban states and tags. Test cases, Shared steps and their relations will not be imported. This option will allow you to import import work items and source code with their relationships in tact.
Use a 3rd party solution - Out of the available options currently OpsHub offers the most complete solution. For test case and source control link migration you're looking at the commercial edition, which comes at a steep price. It still has a long list of known issues and last time I tried it, I ran into numerous issues which required their support to resolve them.
There are specialized TFS consultants who live off these kinds of migrations if your current state of the work items is precious to you, then you could reach out to them.
See also:
https://www.visualstudio.com/en-us/articles/adopting-vsts

Identiify which user created the Continous Integration(CI) Build

Am new to TFS and learning about CI.
Am going to Team Explorer = > Builds to see the list of build definitions created.
How do i identify who(Which user) has created that build definition ?
Am not getting where it is listed !! Hope it is available
Thanks
There is no option in TeamExplorer and I think there is no other way, because even in the database is not listed who created the build definition, only when it was created.
A strange workaround would be to check who changed the folder mappings of a build definition the last time, but this is only possible in database. I'm not very good in SQL and only spent few minutes to get this trashy statement:
SELECT ident.DisplayName
FROM [Tfs_DefaultCollection].[dbo].[tbl_BuildDefinition] as bd, [Tfs_DefaultCollection].[dbo].[tbl_BuildDefinitionWorkspace] as bdw, [Tfs_DefaultCollection].[dbo].[tbl_IdentityMap] as im, [Tfs_Configuration].[dbo].[tbl_Identity] as ident
Where bd.DefinitionId = bdw.DefinitionId
and im.localId = bdw.LastModifiedBy
and ident.Id = im.masterId
and bd.DefinitionName like '%CodedUITests%'
The DefinitionName might not work well with special characters, but you can check in the database how it is written internaly.
You could see who created/changes made to the underlying XAML files but the build definition as such is not exposed as a file in TFS now. So there is no history available. This has been requested as a new feature to MS but not sure when it will be available.
LINK

Compare Lines of Code using VS 2010 & TFS

Using TFS and Visual Studio 2010, is it possible to get a report of the number of lines of code each team member has written?
I know the Annotate feature allows you to see who is responsible for all of the code within a file, but is there anything that would aggregate this into a total number for each team member??
I wrote a powershell script that requires TFS Power Tools and takes an extremely long time to run, and is really kind of embarrassing code because it's the first thing I've written in powershell. You're welcome to grab it from my bitbucket repository. If you fix or improve anything, please send me an update.
All it does recursively go through (almost all) the files from the current path, and run annotate on each one, grab the changeset # from each line and increment a dictionary entry for that changeset, then loops through each changeset and finds the responsible user and adds that changeset's lines into that user's dictionary entry. It spits it out in a html table, so run it like LineCount.ps1 > LineCount.html
You may be able to use http://msdn.microsoft.com/en-us/library/ms244698%28v=VS.90%29.aspx if you're running a version of SQL capable of using data cubes

TFS annotate/blame summary report for a project

In Team Foundation Server, I know that you can use the Annotate feature to see who last edited each line in a particular file (equivalent to "Blame" in CVS). What I'd like to do is akin to running Annotate on every file in a project, and get a summary report of all the developers who have edited a file in the project, and how many lines of code they currently "own" in that project.
Aside from systematically running Annotate of each file, I can't see a way to do this. Any ideas that would make this process faster?
PS - I'm doing to this to see how much of a consultant's code still remains in a particular (rather large) project, not to keep tabs on my developers, in case you're worried about my motivation :)
It's easy enough to use the "tf.exe history" command recursively across a directory of files in TFS. This will tell you who changed what files.
However what you're after is a little bit more than this - you want to know if the latest versions of any files have lines written by a particular user.
The Team Foundation Power Tools ship with a command-line version of annotate called "tfpt.exe annotate". This has a /noprompt option to direct the output to the console, but it only outputs the changeset id - not the user name.
You could also use the TFS VersionControl object model to write a tool that does exactly what you need.
If you install the TFS Power tools (at least for VS2005); it's called annotate.
It might be part of VS2008...
You can use TFS Analysis Cube to see generate a code churn report, which I believe is something you would like.
Annotate is now part of Visual Studio (I think it was introduced in VS 2010).
Docs
I'm writing an answer to an 8 year old question :). Its not really a full answer, but a suggestion to look into excel reports for TFS.
TFS2013 / 2015 on prem has something has an excel report that can be used to visualize Code Churn.
In VS open team explorer then select "Documents" then explode "Excel Reports". I believe Code Churn report has something like discussed. The report is made by some default project template so I think tfs2013 on prem just creates it.
Code Churn Excel Report VS2015
https://msdn.microsoft.com/en-us/library/dd695782.aspx
I had very similar requirement to get details of particular attribute in a file e.g. who added, when, related work items etc.; Following GitHub project is having implementation to get required details and required minimal changes to work with multiple files or project -
SonarQube SCM TFVC plugin
It requires analysis to be executed from Windows machines with the Team Foundation Server Object Model installed (download for TFS 2013).
This blog post is also having good explaination and sample application -
TFS SDK: Connecting to TFS 2010 & TFS 2012 Programmatically

Resources