How to: Add Parameters to Shared Steps
If you have multiple test cases with shared test steps, you can create shared steps to use in all these test cases. This reduces the maintenance for manual test cases. For more information, see How to: Share Common Test Case Steps Using 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. This enables you to run test cases with shared steps multiple times using each iteration of the data in the parameters. For example, if you have shared steps to log into an application then you might add parameters for username and password to run a test multiple times for users who have different permissions. You can add the parameters @username and @password to your shared steps. Then, in your test case you can add multiple values for these parameters depending on the requirements of the specific test.
When you add parameters to your shared steps, you only provide a single iteration of data for the parameters. This data iteration can be used if you want to create an action recording for this shared step. For more information, see How to: Create an Action Recording for Shared Steps.
- Visual Studio Ultimate, Visual Studio Premium, Visual Studio Test Professional
Use the following procedure to insert or delete parameters and add the value for a parameter in your shared steps.
To insert or delete parameters and add the value for a parameter
Open Microsoft Test Manager.
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.
From the Testing Center, choose Organize and then choose Shared Steps Manager.
The Shared Steps Manager pane is displayed.
To add parameters to your shared steps, select the shared steps from the list.
To open the shared steps, choose Open.
Choose where you want to insert your parameter in either Action or Expected Result. Then choose Insert parameter.
The Insert Parameter dialog box is displayed.
Type the name of your parameter and then choose Insert parameter.
The parameter is displayed in the step preceded by @.
The column to add the parameter values for this new parameter is displayed underneath the steps in Default Parameter Value.
Repeat steps 5 to 7 to add all the parameters that you require for your shared steps.
To add the values for the parameters, choose one of the columns for the parameters.
A new row is displayed to use to add a set of parameter values.
Type the values for all your parameters.
You can enter only one set of values for your parameters in your shared steps. These values are used only if you create an action recording for your shared steps. At any time, these will not be added to the test case that includes these shared steps. For more information, see How to: Create an Action Recording for Shared Steps.
(Optional) To delete a parameter from your shared steps, choose the parameter in one of the rows in Parameter Values and then choose Delete parameter.
The Delete parameter dialog box is displayed. You can replace the parameter with a fixed value or just remove it from your steps.
(Optional) To rename a parameter in your shared steps, choose the parameter in one of the rows in Parameter Values and then choose Rename parameter.
The Rename parameter dialog box is displayed. You can then change the name of your parameter throughout your shared steps.
To save the parameters and values that you have added to the test case, choose Save in the toolbar.
To add data for the parameters to the test cases that include these shared steps, open the test case. The parameters are displayed underneath the test steps in Parameter Values. You can now add rows of data for each iteration of the test that you want to run. For more information about how to run the test, see How to: Run Multiple Iterations of a Test Using Different Data Parameters.