แชร์ผ่าน


Share steps between test cases

TFS 2017 | TFS 2015

Many manual tests require performing an identical sequence of steps and test data. For example, logging in to a web app or saving form data are common steps performed in several test sequences. With the use of Shared Steps and Shared Parameters work items, you can minimize the creation of test steps and data that you need to enter and manage. Shared Steps define a sequence of steps that can be referenced by many different test cases. Similarly, Shared Parameters define a set of test data that can be referenced by many different test cases. These work item types are explicitly linked with the Test Cases/Shared Steps and Reference By/References link types as shown in the following image.

Diagram shows Shared Steps connected to Test Case, which is also connected to Shared Parameters.

This article describes how to define and use Shared Steps. To learn how to define and reference Shared Parameters, see Repeat a test with different data.

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.

Create shared steps

While you're editing a test case, select a sequence of steps that you want to share:

Create shared steps

The steps you selected are replaced with a link to the new shared steps work item:

Resulting test case with a shared step.

You can edit shared steps at any time. Any changes you make appear in every test case where you use the shared steps.

You can use parameters in shared steps. For more information about parameters, see parameters.

You provide values for the parameters in the test cases that use the shared steps. You don't have to provide values in the shared steps definition. However, you can provide one default row of values. These values are used when you create an action recording of a standalone shared step.

Insert shared steps into other test cases

Now you can use the shared steps in another test case:

Use shared steps in test cases.

A query opens. Run it to find the steps you want to insert:

Run the query to find shared steps

Mark shared steps when running a test

When you run a test, you can either mark the whole shared sequence as passed or failed, or mark each step separately:

Shared steps in Test Runner.