How to: Share Common Test Case Steps Using Shared Steps

You can share steps between manual test cases by creating shared steps using Microsoft Test Manager. For example, the test steps to log on to your application under test might have to be run in several test cases. By sharing the steps, you have to maintain changes in the shared steps only. You can create shared steps from within a test case, or you can create shared steps in the Shared Steps Manager in Organize. You can also edit and copy shared steps in the Shared Steps Manager if you require.

You can create an action recording for shared steps from the Shared Steps Manager. An action recording enables you to speed up your manual testing by playing back the shared test steps automatically. For more information, see How to: Create an Action Recording for Shared Steps.

If you want to run your test cases that have shared steps multiple times with different data, you can add parameters to the shared steps. For more information about parameters in shared steps, see How to: Add Parameters to Shared Steps.

The following illustration shows you how to create shared steps from existing steps in a test case.

Create Shared Steps

Requirements

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

Note

If you modify shared steps, this can affect other test cases that are using these shared steps. You might want to check that your changes will not cause other test cases to fail.

Use the following procedures to create and use shared steps:

  • Create shared steps from existing steps in a test case

  • Insert shared steps in a test case

  • Create shared steps from the Organize center

To Create Shared Steps from Existing Steps in a Test Case

To create shared steps from existing steps in a test case

  1. Open Microsoft Test Manager.

    Note

    To display the Microsoft Test Manager window, choose Start, and then choose All Programs. Point to Microsoft Visual Studio 2012 and then choose Microsoft Test Manager.

  2. From the Testing Center, choose Plan and then choose Contents.

    The Contents pane is displayed.

  3. Select the test suite in the test suite hierarchy pane that contains your test case.

  4. To open the test case that has the common steps you want to share with other test cases, double-click the test case listed in the Test Suite Details pane.

  5. Choose Steps.

  6. Select the sequence of steps that you want to share. To extend the selection over several steps, hold down SHIFT until you choose the last step.

  7. Right-click and point to Create shared steps.

    The Create Shared Steps dialog box appears.

  8. Type a unique name in Title and choose OK.

    The shared steps are now created and shown as a single step in the test case with a shared-step icon.

  9. (Optional) To view the shared steps, right-click the shared step icon and point to Open shared steps. Or, if you pause your mouse over the shared steps, the details for the shared steps are displayed in the tooltip.

  10. (Optional) To edit these shared steps, right-click the shared steps and point to Open shared steps. Make your changes as required, and then choose Save and Close.

  11. To save the test case, choose Save and Close.

Insert Shared Steps in a Test Case

To insert shared steps in a test case

  1. Open Microsoft Test Manager.

    Note

    To display the Microsoft Test Manager window, choose Start, and then choose All Programs. Point to Microsoft Visual Studio 2012 and then choose Microsoft Test Manager.

  2. From the Testing Center, choose Plan and then choose Contents.

    The Contents pane is displayed.

  3. Select the test suite in the test suite hierarchy pane that contains your test case.

  4. To open the test case that requires the shared steps, double-click the test case listed in the Test Suite Details pane.

  5. Choose Steps.

  6. To add shared steps to the test case, right-click the step where you want to insert the steps and point to Insert shared steps.

    The Add Shared Steps dialog box appears with the list of available shared steps.

  7. (Optional) If there are several shared steps listed, you can narrow your search for shared steps by changing the query, as shown in the following steps.

    1. To add a new clause to your query, select Choose here to add a clause.

    2. Choose each column in the query clause to fill in the clause. If a column has a list of accepted values, a drop-down arrow appears when the column is selected. Choose the drop-down arrow to select a value from the list. The following columns are available:

      Query Column

      How to complete

      And/Or

      Select And if this clause and the previous clause must be true to match a result. Select Or if either this clause or the previous clause must be true to match a result.

      Field

      The list for this field contains all the searchable work item fields used in the current Team Foundation Server. Use as many clauses and fields as you want to get useful results. Press ALT+DOWN ARROW or type the field name that you want to select.

      Operator

      Examples of operator choices are = (equal), <> (not equal to), > (greater than), < (less than), >= (greater than or equal to), <= (less than or equal to), In, Was Ever, Was Never, and Contains.

      Value

      Specifies the value that you are looking for in the specified field. If there is a list of values to select from, choose the drop-down arrow to select the one that you want. Team Foundation work item tracking includes some query variables to dynamically add values to your query.

    3. Repeat the previous two steps to add all the values for which you want to search.

    4. To see the results of your query, choose Run to run the query.

    Note

    You can change the columns of data that are displayed by adding and removing fields as you require. For more information, see How to: Change and Filter the Data Columns in Microsoft Test Manager.

  8. Select the shared steps to insert from the list and then choose Add shared steps.

    The shared steps are inserted above the selected step.

    Note

    You can open the shared steps to view the individual test steps. Right-click the shared steps and point to Open shared steps. Or, if you pause your mouse over the shared steps, the details for the shared steps are displayed in the tooltip.

  9. Choose Save and Close to save the test case.

Create Shared Steps from the Organize Center

To create shared steps from the Organize Center

  1. Open Microsoft Test Manager.

    Note

    To display the Microsoft Test Manager window, choose Start, and then choose All Programs. Point to Microsoft Visual Studio 2012 and then choose Microsoft Test Manager.

  2. From the Testing Center, choose Organize and then choose Shared Steps Manager.

    The Shared Steps Manager pane is displayed.

  3. To create shared steps, choose New.

    The New Shared Steps dialog box is displayed.

  4. To name the shared steps, type the name in Title.

    You use this title to identify the shared steps and search for them if you have to.

  5. Choose Area to select the appropriate area in the team project for the shared steps.

    Note

    The areas are set up by your Team Foundation Server administrator for the team project. You can use the area field to query for shared steps.

  6. Choose Priority to select the importance of the shared steps.

  7. Choose Assigned To to select the appropriate owner for the shared steps.

  8. (Optional) To change the state of shared steps, you must first save the shared steps. After you save the shared steps, you can select a state from the list, based on the following table:

    State

    When to use it

    Active

    The shared steps can be used in any test case.

    Closed

    The shared steps are no longer required for future iterations of this team project.

    Note

    By default, State is set to Active.

  9. (Optional) To add a detailed description of the shared steps, choose Summary and type the details in Description.

  10. Choose Steps.

  11. Choose <click here to add a step>, and then type the details of the test step.

  12. Under Action, type the action that the tester takes to perform this test step.

  13. (Optional) Under Expected Result, type the result the user should expect after the action has been performed.

    Note

    If you add expected results to a test step, it automatically becomes a validation test step shown by the red check mark on the step icon. When you run the shared steps, you must individually mark a validation test step as either passed, or failed. If you do not, the test will automatically be assigned a status of fail.

  14. To add another test step, choose Enter. You can add as many test steps as you require for your shared steps.

  15. To save the shared steps, choose Save and Close in the toolbar.

    The shared steps are displayed in the list in the shared steps manager.

See Also

Tasks

How to: Create a Manual Test Case

How to: Use Shared Steps while Running a Test

How to: Create an Action Recording for Shared Steps

How to: Add Parameters to Shared Steps

Concepts

Creating Manual Test Cases