Jaa


Copy or clone test plans, test suites, and test cases

TFS 2017 | TFS 2015

Several tools support copy, clone, or import operations of test items—such as, test plans, test suites, and test cases. Test cases describe the steps to take to run a test and validate a feature implementation or bug fix. Test suites group test cases, and optionally other test suites, into a particular order. Test plans define a collection of test suites to run for a particular iteration or release.

Each test case is designed to confirm a specific behavior. Test cases may belong to one or more test suites, however test suites can belong to one and only one test plan.

In general, you should create a test plan for every major project milestone. Copy, clone, or import operations of test items support the following scenarios:

  • Define a test plan for a new sprint or release based on an existing test plan
  • Import test suites from one test plan to another test plan within the same or different project
  • Copy test cases for use in different test suites and test plans
  • Share test objects across projects
  • Move test objects from one project to another, possibly to support consolidating projects into a single project.

For an overview of test objects and terminology, see Test objects and terms.

Supported copy, clone, and import tools

Depending on the Azure DevOps version you use, you can use the clients or tools listed in the following table to copy, clone, or import test plans, test suites, or test cases.

Client/tool

Test Plans

Test Suites

Test Cases


Web portal (Grid)

✔️ (Copy and paste)

Work item form

✔️ (Copy)

Microsoft Test Manager1
(deprecated)

✔️ (Clone plan)

✔️ (Create copy)

TCM CLI 2

✔️ (Clone)

✔️ (Clone)

✔️ (Import automated)

Note

  1. Microsoft Test Manager (MTM) was deprecated for use with Azure DevOps Services in January 2020, and isn't supported for Azure DevOps Server 2020 and later versions. The current version of Azure Test Plans supports all features that MTM supported and more.
  1. The Test Case Management (TCM) command-line tool is installed when you install Visual Studio 2017 or earlier versions. Examples provided in this article reflect the options available with the Visual Studio 2017 version. Earlier versions may support fewer options. For details, see Work with the TCM command-line tool.

Prerequisites

  • You must connect to a project. If you don't have a project yet, create one.

  • You must be added to a project. To get added, Add users to a project or team.

  • To view test-related work items, you must have Basic access or higher and permissions to view work items under the corresponding Area Path.

  • To add test plans and test suites, manual test cases, delete test artifacts, and define test configurations you must have Basic + Test Plans access level or have one of the following Visual Studio subscriptions:

  • To add or edit test-related artifacts, you must have the following permissions:

    • To add or modify test plans, test suites, test cases, or other test-based work item types, you must have Edit work items in this node permission set to Allow under the corresponding Area Path.
    • To modify test plan properties such as build and test settings, you must have Manage test plans permission set to Allow under the corresponding Area Path.
    • To create and delete test suites, add, and remove test cases from test suites, change test configurations associated with test suites, and modify a test suite hierarchy (move a test suite), you must have Manage test suites permission set to Allow under the corresponding Area Path.

To learn more, see Manual test access and permissions.

Work with the TCM command-line tool

To exercise the TCM command-line tool, you must have the following in place:

  • Installed Visual Studio 2017 Professional or earlier version. You access TCM from the command prompt and the following directories: %programfiles(x86)%\Microsoft Visual Studio\2017\Professional\Common7\IDE
    %programfiles(x86)%\Microsoft Visual Studio\2017\Enterprise\Common7\IDE %programfiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE

  • To run a TCM command, specify the /collection and /teamproject parameters, and /login as needed.

    Parameter Description
    /collection:CollectionURL Required. Specifies the URI of the team project collection.The format for the URI is as follows:
    - For Azure DevOps Services: http://dev.azure.com/OrganizationName
    - For Azure DevOps Server: http://ServerName:Port/VirtualDirectoryName/CollectionName. If no virtual directory is used, then the format for the URI is as follows:http://ServerName:Port/CollectionName
    /teamproject:project Required. The name of the project that contains the test objects you want to clone or import automated tests into.
    /login:username,[password] Optional. Specifies the name and password of a valid Azure DevOps user and who has permissions to run the command. Use this option if your Windows credentials don't have the appropriate permissions, or you're using basic authentication, or you're not connected to a domain.
  • You must be a valid member of the project(s) you want to access and have the required permissions based on the commands you run. To learn more, see Manual test access and permissions.

  • To clone or import test objects, you must have been granted the same access levels required to add test plans and test suites as described in Prerequisites.

List test plans or test suites

You often need to know the ID assigned to a test plan or test suite to support copy, clone, or import operations.

You can generate a list of test plans, test suites, or other test objects from the Boards>Queries page. For example, by setting the Work Item Type=Test Plan, you can list all test plans defined for the team project. If you choose the Query across all projects checkbox, the query will list all test plans defined for all projects. To learn more about defining queries, see Define a work item query.

Tip

While test plans, test suites, and test cases are related to each other, you can't view the relationships through a work item query. Link types aren't used to link test plans, test suites, and test cases. Only shared steps and shared parameters are linked to test cases. Also, test cases are linked to user stories or other work items that they test.

Screenshot of Query Editor, Query test plans.

Copy or clone test plans

We recommend creating a new test plan per sprint or release. When doing so, generally you can clone the test plan for the prior cycle and, with few changes, the copied test plan is ready for the new cycle.

Cloning is useful when you want to branch your application into two versions. After cloning, tests for the two versions can be changed without affecting each other.

Conceptual image, clone test plan.

Note

This feature isn't supported through the web portal for Azure DevOps Server 2019 and earlier versions. The feature to copy test plans requires Azure DevOps Server 2020 or later version.

Import or clone test suites

When you're creating the test plan for a new sprint, you often want to repeat some of the tests from the previous sprints, to make sure that the functionality you already implemented still works.

Conceptual image, copy test suites.

Note the following:

  • When you import (Web) or clone (TCM) a test suite to a new project, the new suite will contain copies of all test cases in the source suite. However, it won't retain any historical data like the previous test runs, related bugs, old results.
  • Shared steps referenced by the test cases are also cloned and created in the destination project.
  • You can't clone test cases from and to the same test plan, even into a different suite. To accomplish this scenario, you must first move the test cases to a different, temporary test plan. Then, use the temporary test plan as the source plan and clone the test cases back to the source test plan by putting the ID into the destination test plan place. Shared steps present in the test cases will also be duplicated in this process.

You can use MTM or TCM to clone a test suite, specifying the target test plan, which can be within the same or another project. You can also specify a custom test suite work item type.

You can use tcm suites /list to list all test suites defined for a project.

In order to use the same test cases in different suites and plans, copy and paste test cases using the Grid view. To learn more, see (XLink to be provided)

Note

This feature isn't supported through the web portal for Azure DevOps Server 2019 and earlier versions. The feature to import test suites requires Azure DevOps Server 2020 or later version.

Copy and paste test case(s) (Grid view)

You copy and paste test cases in order to use the same tests in different suites and plans. For example, you could have a test suite that uses a subset of the tests defined in a more exhaustive test suite. The Define>Grid view supports editing test cases as well as copy and pasting test cases to different test suites. For editing test cases, see Create test cases, Use the Grid view to edit test cases.

Tip

Don't copy test cases when what you really want to do is test with different configurations or different data.

From the Internet Explorer, Edge, or Chrome browsers, you can copy test cases from the Grid view for one test plan and test suite to another test plan and test suite.

  1. From the Test Plans>Test plans page, choose the test suite containing the test case(s) you want to copy. Within the Define tab, Choose the Grid view.

  2. Highlight the rows you want to copy, and then enter CTRL+C.

    Copy test cases from Grid view.

  3. Select a different test suite from the same or different plan and paste with CTRL+V. If you don't select a different suite, nothing happens when you paste, because each suite can only have one reference to any test case.

  4. Choose Save test cases.

    The new test cases are saved with new IDs assigned.

    Saved test cases pasted into Grid view.

Import automated test cases (TCM)

To import automated test cases to a test suite, use tcm testcase /import. You must specify a .dll file for the test assembly that contains your tests.

tcm testcase /import /collection:teamprojectcollectionurl /teamproject:project
             /storage:path
             [/maxpriority:priority]
             [/minpriority:priority]
             [/category:filter]
             [/syncsuite:id [/include]]
             [/login:username,[password]]
Parameter Description
/storage:path Specifies the path and name of the test assembly that contains your automated tests that you want to import.
/maxpriority:priority Optional. Specifies which tests to import based on the maximum priority of the test method. For example, if the parameter is /maxpriority:1, only tests with a priority attribute for the test method less than or equal to 1 are imported as test cases from the assembly.
/minpriority:priority Optional. Specifies which tests to import based on the minimum priority of the test method. For example, if the parameter is /minpriority:2, only tests with a priority attribute for the test method equal or greater than 2 are imported as test cases from the assembly.
/category:filter Optional. Specifies which tests to import based on the category of each test method in the test assembly. You can use this parameter together with /syncsuite to import tests with a certain category into a specific test suite.
For more information about test categories, see Run unit tests with Test Explorer.
/syncsuite:id Optional. Specifies the suite ID for the test suite in your test plan to which you want to add the test cases that you import. This suite cannot be a dynamic suite or a query-based suite. If you specify a test suite to synchronize to update tests that have already been added, the tests that aren't imported are removed from the test suite but not from the test plan itself.

For descriptions of /collection, /teamproject and /login parameters, see Work with the TCM command-line tool.

Next step

Microsoft Test Manager (deprecated)