Share via


Copying and Cloning Test Suites and Test Cases

There are several ways to duplicate test suites and test cases in Microsoft Visual Studio Team Foundation Server (TFS).

  • Duplicate a single test case in a test suite in Microsoft Test Manager.

    This feature is useful when you want to author a new test case that is similar to an existing one.

  • Copy a test suite from another test plan in Microsoft Test Manager (copy by reference or shallow copy).

    A test suite and any contained suites are copied, but the test cases are not copied. The source and destination test plans share the same test cases. After the copy, you can add or remove test cases from either plan without affecting the other; however, if you edit a shared test case, the changes will impact both test plans.

    This is the most frequently used copy operation. It is useful when you are creating a new test suite for the next iteration or sprint, and you want to repeat the most important tests from previous sprints.

    Copying test suites

  • Cloning test suites by using tcm.exe (copy by value or deep copy) creates new test cases in the destination test plan. These new test cases are copies of the test cases in your source test plan. After the copy, you can edit the test cases in either plan without affecting the other. Cloning test suites is useful when you want to work on two differing releases simultaneously. The source and target suites must be in the same team project collection.

    Note

    If you have not installed Visual Studio 2012.1 – Visual Studio and TFS: The source and target suites must be in the same team project.

    Cloning test suites

    Tip

    If you have installed Visual Studio 2012.2, you can perform cloning operations from Microsoft Test Manager. See To clone a test suite from Microsoft Test Manager

Requirements

  • Visual Studio Ultimate, Visual Studio Premium, Visual Studio Test Professional

To duplicate a single test case

This feature is useful when you want to author a new test case that is similar to an existing one.

  1. In Microsoft Test Manager, choose Testing Center, Plan, Contents.

  2. Select a test suite and a test case.

  3. In the toolbar of the test case list, choose Create a copy of the selected test case and add to this suite.

To copy test suites from another test plan

Copy Test Suites From Another Test Plan

  1. In Microsoft Test Manager choose Testing Center, Plan, Contents.

  2. Select a static test suite into which you want to copy the older suite.

    In the toolbar of the test suites hierarchy, choose Copy test suites from another test plan and follow the wizard.

    The test suite and any suites it contains are copied, but the test cases are not copied. The source and destination test plans share the same test cases.

After the copy, you can add or remove test cases from either plan without affecting the other; however, if you edit a shared test case, the changes will impact both test plans.

To clone a test suite and its test cases

Cloning is useful if you want to develop different versions of an application: after copying, the tests for the two versions can be changed without affecting each other.

Open the Developer Command Prompt. Alternatively, use a standard command prompt and change directory to %VS110COMNTOOLS%..\IDE. Use tcm.exe:

cd %VS110COMNTOOLS%..\IDE

tcm suites /clone     
   /collection:https://Server:8080/tfs/Collection 
   /teamproject:"TeamProject"
   [/destinationteamproject: "DestinationProject"]
   /suiteid:sourceId 
   /destinationsuiteid:targetId 
   [/clonerequirements] 
   [/overridefield:"field name"="new value"] [/overridefield:"field 2"="value 2" ...]] 

Parameters:

  • Server, Collection, TeamProject: The names of your team foundation server, team project collection, and team project.

  • destinationTeamProject: Specify this if the destination test suite is in a different team project. It must be in the same team project collection. You must specify override field values for "Iteration Path" and "Area Path".

  • suiteId and destinationSuiteId: The ID of the suite to be copied, and the ID of the suite into which the new copy will be added. If you want to copy a whole test plan, use the ID of the suite at the root of the test plan.

    The ID of a suite is displayed in the details pane when you select it in the test plan.

    You can also get a list of suites by using tcm suites /list.

  • /clonerequirements: Clone requirements work items that are attached to requirements-based test suites. If you omit this parameter, requirements-based test suites are converted to static suites.

  • /overridefield:"field name"="new value": Change the value of a field in each cloned work item. You can use multiple occurrences of this parameter to change as many fields as you want.

  • (Deprecated)/fieldname:"field name" /fieldvalue:"new value": Change the value of a field in each cloned work item. You could use this to change the iteration path when you copy a suite from one sprint to another.

    If you have installed Visual Studio 2012. 1 – Visual Studio and TFS, use /overridefield instead. You can change only one field by using /fieldname and /fieldvalue.

Note

/destinationTeamProject, /clonerequirements and /overridefield are available only if you have installed Visual Studio 2012.1 – Visual Studio and TFS.

Examples:

tcm suites /clone /collection:http://tfs.fabrikam.com:8080/tfs/DefaultCollection
   /teamproject:IceCream /destinationteamproject:ToyStore
   /clonerequirements
   /suiteid:234 /destinationsuiteid:567 
   /overridefield:"Iteration Path"="ToyStore\sprint3"
   /overridefield:"Area Path"="ToyStore\catalog"

The following example works without Visual Studio 2012.1:

tcm suites /clone /collection:http://tfs.fabrikam.com:8080/tfs/DefaultCollection 
   /teamproject:IceCream 
   /suiteid:234 /destinationsuiteid:567 
   /fieldname:"Iteration Path" /fieldValue:"IceCream\sprint3"

To clone a test suite from Microsoft Test Manager

With Visual Studio 2012.2 installed, you can clone a test plan in Microsoft Test Manager by selecting the Test Plan Manager in the Organize tab of the Testing Center.

Open the context menu for the test plan and choose Clone to open the Clone a test plan dialog box and perform your cloning operation.

Clone a test plan

Adjustments to be made after a clone

  • Update query-based suites if you have overridden field values in the clone operation. For example, if you provided an override value for Area Path and you have a query-based suite that depends on Area Path, consider editing the query. For more information, see Organizing Test Cases Using Test Suites.

  • With /clonerequirements: Add detail to the new requirements. The clone operation creates a new requirement work item (product backlog item or user story) for each cloned requirement suite. Edit the new requirements to be appropriate for the new test plan.

    Without /clonerequirements: Create new requirements and requirements-based suites. Without /clonerequirements, the clone operation converts requirements-based test suites into static suites, and the new test cases are no longer linked to any requirement work item. Therefore, you might want to create requirements work items (product backlog items or user stories), create suites from them, and then move the test cases into those suites. For more information, see Organizing Test Cases Using Test Suites.

  • Specify a build in the destination test plan if you have cloned automated test cases. For more information, see How to: Associate an Automated Test with a Test Case.

What Gets Cloned?

When you clone a test suite using tcm.exe, the following objects are copied from the source test plan to the destination test plan:

Test plan object

Copied

Notes

Test case

Topic applies

Each new test case retains its shared steps.

A link is made between the source and new test cases.

The new test cases do not have test runs, bugs, test results, and build information.

Shared steps referenced by cloned test cases

Topic applies

Test suite

Topic applies

The following data is retained:

  • Names and hierarchical structure of the test suites

  • Order of the test cases

  • Assigned testers

  • Configurations

Action Recordings linked from a cloned test case

Topic applies

Links and Attachments

Topic applies

Test configuration

Topic applies

The test configuration is reapplied in the destination test plan.

Test settings

Topic does not apply

The test setting for the destination test plan is applied.

Test results

Topic does not apply

Test runs and exploratory test sessions

Topic does not apply

Because test runs are applicable only to the source test plan, they are not copied.

Requirements-based suites

Topic does not apply

Without /clonerequirements

Requirements-based test suites are converted to static test suites in the destination test plan. Cloned test cases will be referenced under this static test suite.

Cloned test cases do not include links to their original requirements work items.

Requirements-based suites

Topic applies

[Visual Studio 2012.1] with /clonerequirements

Copied and linked to a new copy of the requirement work item.

Requirements work items (product backlog items or user stories)

[Visual Studio 2012.1] with /clonerequirements

Requirements work items that are associated with a cloned requirements-based suite are cloned.

Bug work items

[Visual Studio 2012.1] with /clonerequirements

[Visual Studio 2012.1] with /clonerequirements

Cloned in a team project that uses the Scrum process template, or any project in which the Bug work item type is in the Requirements work item category.

In other projects, bugs are not cloned.

Example test suite cloned by using tcm.exe

Source Test Plan

Source test plan

Destination Test Plan

Destination test plan

See Also

Concepts

Defining a Test Plan

Organizing Test Cases Using Test Suites

Creating Tests for Product Backlog Items, User Stories, or Requirements