संपादित करें

इसके माध्यम से साझा किया गया


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

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

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 might 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 more information, see Overview of test objects and terms.

Prerequisites

  • Access Levels:

  • Permissions: To add or edit test-related artifacts:

    • Edit work items in this node permission set to Allow under the corresponding Area Path, to add or modify test plans, test suites, test cases, or other test-based work item types.
    • Manage test plans permission set to Allow under the corresponding Area Path, to modify test plan properties such as build and test settings.
    • Manage test suites 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).

For more information, see Manual test access and permissions.

Work with the TCM command-line tool

To use the TCM command-line tool, you must have the following items 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 one or more projects that you want to access and have the required permissions based on the commands you run. For more information, see Manual test access and permissions.

  • You must have the same access levels required to add test plans and test suites to clone or import test objects.

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 1

✔️ Copy

✔️ Import

✔️ Copy ✔️ Bulk export/import

Web portal (Grid)

Web portal (Grid)

Work item form

✔️ Copy

Microsoft Test Manager1
(deprecated)

✔️ Clone plan

✔️ Create copy

TCM CLI 2

✔️ Clone

✔️ Clone

REST API 3

✔️ Clone

✔️ Clone

Note

  1. With the release of Azure DevOps Server 2020, the web portal for Azure Test Plans was significantly updated. Many new features were added to support copy, clone, import, and export. For an overview, see Navigate Test Plans.
  2. 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.
  3. REST API commands to support cloning of test plans and test suites were added with version 5.0, corresponding with Azure DevOps 2019.
  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.
  2. The Test Case Management (TCM) command-line tool installs 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 more information, see Work with the TCM command-line tool.

List test plans or test suites

When you perform copy, clone, or import operations related to test plans or test suites, it’s essential to have access to their unique ID. This identifier allows you to precisely target the specific plan or suite you want to work with. By knowing the assigned ID, you can streamline your testing processes and ensure accurate replication or transfer of test-related data.

Do the following steps to generate a list of test plans, test suites, or other test objects.

  1. Select Boards > Queries, from your project.
  2. Enter the parameter, Work Item Type=Test Plan in your query Editor. You can list all test plans defined for the team project.
  3. Enter a check in the Query across projects checkbox. The query lists all test plans defined for all projects. For more information, see Define a work item query.
  4. Run the 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 don't link test plans, test suites, and test cases. Only shared steps and shared parameters link to test cases. Also, test cases link to user stories or other work items that they test.

Screenshot of Query Editor.

Copy or clone test plans

When you create a new test plan per sprint or release, a helpful approach is to clone the test plan from the prior cycle. With minimal adjustments, the copied test plan becomes well-suited for the new cycle. This practice streamlines the planning process and ensures consistency across iterations.

Cloning proves especially useful when you need to branch your application into two versions. After cloning, you can modify tests independently for each version without impacting the other. It’s an efficient way to manage testing efforts while maintaining separation between different application variants.

Conceptual image, clone test plan.

  1. Select Test Plans > Test plans, from your project.

  2. Choose the test plan you want to copy from the Mine or All page.

  3. Select More actions > Copy test plan. This option lets you copy or clone test plans within a project.

    Screenshot showing Test Plan More Actions menu, copy test plan option.

  4. Specify the name of the new test plan, and select an Area Path and Iteration Path for the plan.

    Screenshot showing Copy test plan dialog.

    • Choose one or the other radio-buttons based on the following guidance:
      • Reference existing test cases: Choose this option when you plan to merge the two branches eventually. In this case, keep the same requirements for functionality that is already implemented and tested.
      • Duplicate existing test cases: Choose this option when you want to make new user stories or requirements maintained separately. If you plan to diverge into two similar but separate applications, you might want to change the user stories of one without changing the stories of the other. Choosing this option creates an independent set of requirements for the new test cases.

    If you duplicate existing test cases, the copied test cases get assigned the Area Path and Iteration Path specified for the cloned test plan.

    For more information, see About area and iteration (sprint) paths.

    The page refreshes to display the newly copied test plan.

    Screenshot showing Copied test plan, browser view.

  5. Update any query-based suites that you copied to use the new area and iteration paths.

  6. Specify a build in the destination test plan if you cloned automated test cases.

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.

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

  • When you import (Web) or clone (TCM) a test suite to a new project, the new suite contains copies of all test cases in the source suite. However, it doesn'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 are also duplicated in this process.

When you're working with Azure Test Plans, you can import a test suite from one test plan into another test plan within the current project. It doesn't matter whether the test plans are within the same project. This process involves copying or cloning the test suite, resulting in the creation of a new test suite. Additionally, any subtest suites also get duplicated. The test cases referenced by the test suites don't duplicate; instead, they get referenced by the cloned test suites.

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

To use the same test cases in different suites and plans, copy and paste test cases using the Grid view.

  1. Select Test Plans > Test plans.

  2. Choose the test plan where you want to import a test suite from the Mine or All page.

  3. Select More actions > Copy test plan. This option lets you copy or clone test plans within a project.

    Screenshot showing Test Suite More Actions menu, Import test suites option.

  4. In the opened dialog, select the project if the test plan resides within a different project. Otherwise, enter the Test Plan Name or ID and Test Suite Name or ID. You can also select the name or ID from the dropdown menus.

  5. Create the import. You can only import one suite from a test plan at a time.

    Screenshot showing Import suites from a Test Plan dialog.

    The following message displays:

    Screenshot showing Import suites initiated message.

  6. When the import operation completes, the following message displays. Select Refresh to refresh your browser.

    Screenshot showing Import suites completed message.

    The newly added test suite then displays.

    Screenshot showing Imported test suite displayed.

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 test case

From the web portal, you can copy test cases from within a project or another project to a test suite, or you can use the Grid view to copy and paste test cases from one suite to another. Optionally, you can bulk import and export test cases.

Tip

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

You have the flexibility to copy test cases from either within a project or from another project within the organization or collection. Additionally, you can choose to include all links and attachments during the copying process.

  1. Select Test Plans > Test plans.

  2. Choose the Test Plan that contains one or more test cases you want to copy from the Mine or All page.

  3. Select the Test Suite that contains one or more test cases you want to copy.

  4. From the Define page, select the check box for all test cases you want to copy.

  5. Select More actions > Copy test case.

    Screenshot showing Test Cases More Actions menu, copy test cases option.

  6. Choose the Project from the dropdown menu, and then enter the Test Plan Name or ID and Test Suite Name or ID. You can also select the name or ID from the dropdown menus.

    Screenshot showing Copy test cases dialog.

  7. (Optional) Select the check boxes for Include existing links and Include existing attachments.

  8. Create the copy.

    The background copy operation depends on the quantity and complexity of the selected test cases. After completion, a notification gets sent to you confirming the operation’s success and a link to the test suite where the copied test cases reside.

Copy and paste test case (Grid view)

When you're managing test cases, copying and pasting serve as a valuable technique to reuse the same tests across various suites and plans. For instance, consider a scenario where you have a comprehensive test suite, and you want to create a more focused subset of tests within another suite. The Define > Grid view provides support for both editing test cases and copying them to different test suites. For more information, see Create test cases, Use the Grid view to edit test cases.

Tip

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

From the Internet Explorer, Microsoft 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 one or more test cases you want to copy. Within the Define tab, select Grid View.

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

    Screenshot showing 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 save with new IDs assigned.

    Screenshot showing saved test cases pasted into Grid view.

Bulk import or export test cases

From the web portal, you can perform a bulk import or export of test cases from/to a test suite. Test cases are defined in a comma-separated values (CSV) file.

Export test cases

  1. From the Test Plans > Test plans page, choose the test plan with the test suite containing the test cases you want to export.

  2. Optional. Choose Column options to add fields to include in the download file.

  3. To export all test cases for the test suite, choose Export test cases to CSV.

    Screenshot of Export test cases from the selected test suite.

    To export a subset of test cases for the test suite, select the test cases to export, choose More options, and select Export test case(s) to CSV.

    Screenshot of selected test cases, Export test cases to CSV.

  4. The exported CSV file appears in your Downloads folder.

Import test cases

  1. From Test Plans > Test plans, choose the test plan with the test suite into which you want to import test cases.

    Screenshot of Import test cases to the selected test suite.

  2. Choose the file to import from the opened dialog, and then select Import.

    Screenshot showing Import Test Cases dialog.

  3. Select Confirm. If you specify test cases that are already defined in the test suite, some elements might get over written during import.

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 can't be a dynamic suite or a query-based suite. If you specify a test suite to synchronize to update added tests, 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.

Limitations

  • The test case state column must be in Design state.
  • The test case title length must not exceed 128 characters.
  • There's a limit of 20 MB on JSON objects created during import and export. If the import fails, try the operation with small subset of the test cases.
  • The user performing the import must have permissions on the area and iteration paths for test plan and test suite they're planning to import or export.
  • Copy and Import operations fail if the related link count exceeds 1000 for the test case.

REST APIs

You can copy and clone test plans and test suites using the following REST APIs.

Next steps