0

Referencing and Copying Test Cases in MTM 2013, a Lesson in Patience

by Angela 22. August 2014 15:49

Recently, I’ve had some lengthy discussions about test case, suite, and plan copying in Microsoft Test Manager (MTM), and it something that a lot of people are struggling with. In some cases, people are not even aware that you can do all of these things, let alone the subtle differences around what they are doing behind the scenes. Either way, hope this sheds some light on another way that MTM helps you to manage your testing efforts. There are a handful of methods for reusing test cases across multiple test suites and plans.

1) Add existing test cases – also known as re-using a test case by referencing it. So, in MTM, test cases are by default REFERENCED when you add them to test plans/suites.  You do this through the Add button in the Plan tab of MTM.

image

The implication for using Add is that you need the EXACT SAME test case in multiple places, and if the test case changes it needs to change everywhere. So if I add a test case to 3 different test suites, any change to the test case is reflected in all 3 places automatically. Think of the test case instances that you see in the suites as pointers back to the original test case. Handy! Or annoying depending on your test versioning strategy. As an added bonus, with Add you can pull in test cases from any test plan in the team project collection by simply removing the @Project clause on the query!

image

 

2) Create test suites by referencing existing test cases performs a shallow copy of test suites from a different test plan within the current team project, allowing you to easily reference its test cases. There are 2 places where you will find this option, in the context menu of the Test Plan, as well as in the MTM menu bar of the Plan | Contents tab.

image

image

In MTM 2010, this option was called “Copy test suites from another plan” , which to most reasonable folks sounded like it copied everything. But it was not really a full copy of everything, it was actually a brand new test suite based on the original suite, and the suite contains REFERENCES back to the original test cases. As you can see, in MTM 2013, the menu option is now more explicit about what it is doing. The brand new suite has a new ID and the same name as the original test suite, it also includes all of the original test cases but is just referencing the test cases and their associated requirements. Changing the new test suite does not affect the original suite, but remember that changing the test cases in the new test suite would change the test cases in the original test suite. Also, note that this can only happen across different test plans in the same Team Project, so you cannot use this feature to duplicate test suites into the test plan you are currently in, or to duplicate test suites across Team Project boundaries. Maybe that is an edge case, but people have asked me if they could do it.

But what about the cases where you really do need to effectively BRANCH those test cases?  Say you have a new version of some functionality, but you still need to support the original functionality, and so you need to have two slightly different versions of the same test case. Well, you have yet another option – Copy. Technically you have a few more options yet.

3) Create copy and add to suite is a shallow clone operation on just a single test case. Accessible in the MTM client, you just right click on any test case, and use this tool to create a new copy of the test case, and save it into the test suite that you are currently in. All links, comments, steps, parameters (shared and otherwise), and properties are carried over - but new versions of all of these related items were not created. The new test case refers back to the same links, parameters, etc. of the original test case, and even links back to the original test case so you can see how it originated. Test run results associated to the test case are NOT copied over. Attachments are NOT copied in this case either. And again the scope is the current Team project, current test plan, and current test suite. I cannot cross Team project, test plan, or test suite boundaries with this command.

image

But we’re not done!

4) You might have noticed a Copy (CTRL + C) option in that context menu in the MTM desktop client as well. Don’t be fooled, this just creates another reference to the original test case wherever you paste.  So while it is similar to using the Add button, I can only Copy a test case using this command into another test suite within the same test plan. In other words, it does not work across Team Project or Test Plan boundaries, but it MUST be used across test suite boundaries. And in this case, Copy actually means reference, instead of you know, copy. I know, really? OK, one more option to cover in this blog post.

5) Create a copy of this work item (including links) is the Copy option available only on the web, and it is slightly different than the options available in the desktop version of MTM. This appears to just be the standard Copy Work Item context menu option that you can access anywhere on the web, and nothing specific to the test tools. Clear as mud, right?

Honestly, I’m also having a hard time understanding how it is SUPPOSED to work because it has some odd behavior in my opinion (on VSOnline anyway). It allows you to specify a “Project” in the creation dialog, which I assume means TEAM PROJECT, like it does when you are creating copies of any other work item type from the web. The new test case work item is created in the specified project, with the same references as the original work item, but also adds it to the existing test suite in the current project. I assumed it would only create the new test case in the team project specified. Apparently not. So it does the same type of copy that Create copy and add to suite does, but allows you to do it across team project boundaries. image

image 

Frustrated yet? I know I am and I’ve been using these tools for years. It’s a lot to keep straight, and even I sometimes forget which options bring over which links and artifacts so I have to refer back to the handy tables available on MSDN.  Definitely talk to your team and decide which options to use and when.

Oh, yeah, and cloning is also an option now, but that is another larger discussion so stay tuned for another blog post on that one.

Powered by BlogEngine.NET 2.7.0.0
Original Design by Laptop Geek, Adapted by onesoft