How to: Add Requirements or User Stories to Your Test Plan

If you plan your testing based on requirements or user stories, then you can use Microsoft Test Manager to add requirements or a user stories to your test plan. This enables you to organize your testing by requirements. You can link test cases to existing requirements or user stories that have been created in your team project. You can also view any test cases that have been linked already to the requirement or user story.

By adding the requirement to a test plan with Visual Studio 2010 Ultimate or Visual Studio Test Professional, you make sure that each requirement is specifically tested. This also enables you to determine how much test coverage you have for your requirement. By including the requirement in the test plan, you can run all its test cases at the same time and view the results.

Note

You can add a new requirement to your team project using Microsoft Test Manager. For information about how to do this, see How to: Create a Work Item using Microsoft Test Manager. For information about how to add a new requirement using Microsoft Visual Studio 2010, see User Story (Agile).

After you add a requirement to your test plan, you can then create test cases for that requirement, or add existing test cases to it. You can also edit a test case directly and link it to the requirement using a Tests link and this test case will also be displayed in your test plan.

Link Test Cases to Requirements or User Stories

Note

In your project, requirements might also be called user stories, depending on your methodology.

Use the following procedures to add a requirement to your test plan and link existing test cases or create test cases for this requirement:

  • Add an existing requirement to your test plan

  • Link existing test cases to a requirement

  • Create a test case for a requirement

  • Remove the link between a test case and a requirement

Note

You can also link test cases to requirements or user stories using Microsoft Visual Studio 2010. For more information, see Test Case (Agile). If you do update or add links using Microsoft Visual Studio 2010, the changes are not reflected in Microsoft Test Manager unless you select the requirement and click Refresh. Otherwise the information is not updated immediately.

Add an existing requirement to your test plan

To add an existing requirement to your test plan

  1. Open Microsoft Test Manager.

    Note

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

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

    The Contents pane is displayed.

  3. To add a requirement to your test plan, select the location where you want to place it in the test suite hierarchy and then click Add requirements.

    The Add existing requirements to this test plan dialog box is displayed.

    Note

    The test suite hierarchy has a root node that has the same name as the test plan. You can add test cases, test suites or requirements to this test suite root node, but you cannot rename it.

  4. Select any requirements that you want to add to the test plan, and then click Add requirements to this test plan.

    Note

    Any existing test cases that are already linked to these requirements are displayed in the test suite details pane when you select the requirement in the test suite hierarchy.

    Warning

    Modifying the default query that is displayed for Add existing requirements to this test plan to include non-requirements category work item types might not return expected results. For more information about how to search for other work item types, see How to: Search for Test Cases from Microsoft Test Manager, How to: Create and Manage Queries for Searching and Finding Bugs, Tasks, and Other Work Items.

  5. (Optional) By default, the requirement-based test suite is given the name of the requirement id followed by the name of the requirement. To rename it, right-click the name and point to Rename. Then type the new name.

    The name will also be displayed in the test suite details pane.

  6. (Optional) Click State and select from the list of states based on the following table:

    State

    When to use it

    In Planning

    If you are not yet ready to run the tests linked to this requirement.

    In Progress

    When you are ready to run the tests linked to this requirement.

    Completed

    When you have finished running the tests for this requirement and the quality level reached meets your goals.

    Important

    To run tests, you must set the status of the requirement to In Progress.

  7. To change the default configurations for the requirement that you added, if you want them to be different from the default configurations for the plan, click the drop-down arrow next to the list of configurations in the test suite details pane.

    A dialog box is displayed that shows all the configurations for your team project and the current default configurations for your test plan.

  8. You must first clear Use configurations from parent test suite, and then select the default configurations that you want to add and any that you want to remove.

    Note

    Changing the default configurations only affects new test cases or test suites that are added to this test suite. For more information about how to change the pairings of tests and configurations that are already in your test plan, see the procedure about how to update configurations for specific test cases.

  9. (Optional) To add a new configuration or manage existing configurations, click Manage.

    The Test Configuration Manager activity is displayed. For more information about how to create configurations using the test configuration manager, see How to: Create Test Configurations.

  10. To save your changes to the default configurations, click Save.

  1. From the Testing Center, click Plan and then click Contents.

    The Contents pane is displayed.

  2. Select the requirement in the test suite hierarchy pane that you want to add test cases to, and then click Add.

    The Add test cases to suite dialog box is displayed. All available test cases are shown in the list of tests.

    Note

    Tests that have already been added to the requirement are not shown in the list of tests.

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

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

    2. Click 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. Click 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, click 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. For more information, see Query Variables.

    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, click Run to run the query.

  4. Select the tests that you want to add, and then click Add test cases.

    The test cases that you selected are now displayed in the test suite details pane. The changes that you have made to the requirement in the test plan are automatically saved.

    Note

    All the existing test cases that you add are paired with each default configuration to define what tests must be run on which configurations for the test plan. To see these pairings, select the tests in the test suite details pane and then click Configurations.

Create a Test Case for a Requirement

To create a test case for a requirement

  1. From the Testing Center, click Plan and then click Contents.

    The Contents pane is displayed.

  2. Select the requirement in the test suite hierarchy pane that you want to create a test case for, and then click New.

    The New Test Case dialog box is displayed.

  3. Enter the details for your new test case including the actions and expected results for each test step, and then click Save and Close.

    The new test case is now displayed in the test suite details pane.

    Note

    For more information about how to create new test cases, see How to: Create a Manual Test Case.

  4. Repeat the previous two steps to add more test cases.

    The changes that you have made to the requirement in the test plan are automatically saved.

    Note   To add a copy of an existing test case to the requirement, right-click a test case in the test suite details pane and point to Create copy and add to suite. The new test case dialog box is displayed so that you can edit the test case as necessary.

You can edit the requirement and remove the test case, or you can edit the test case and remove the link to the requirement. The effect is the same.

  1. From the Testing Center, click Plan and then click Contents.

    The Contents pane is displayed.

  2. To remove the link between a requirement and a test case, select the specific requirement in the test suite hierarchy.

    All the existing tests linked to that requirement are displayed in the test suite details pane.

  3. Right-click the test in the list of existing tests, and point to Remove.

    In the Tested User Stories tab for the test case, the Tests link for this requirement is removed. The test case is no longer displayed in the list of tests for this suite. This change you have made to the requirement are automatically saved.

    Note

    You can edit a test case directly and remove the Tests link for any requirement from the Tested User Stories tab.

See Also

Tasks

How to: Create a Manual Test Case

How to: View Requirements or User Stories Using Microsoft Test Manager

How to: Change the Testing State of Test Suites

Concepts

Creating a Test Plan Using Requirements or User Stories

Organizing Test Cases Using Test Suites