Walkthrough: Managing Tests Using Lists and Properties

By using test lists, you can logically group tests and then work with those tests as groups instead of individually. Test lists are especially useful when you have a large number of tests.

Prerequisites

Follow the steps in the procedure "Create a Unit Test" in Walkthrough: Creating and Running Unit Tests.

Manage Tests Using Test lists

To manage tests using test lists

  1. In Visual Studio, open the Test Manager window. To do this, click Windows on the Test menu and then click Test Manager.

    Note

    The Test Manager window initially displays three folders: Lists of Tests, Tests Not in a List, and All Loaded Tests. After a test is generated, it is automatically placed in the Tests Not in a List folder.

  2. Click the All Loaded Tests folder in the Test Manager window.

    All the tests in the current project are displayed.

  3. To create a new test list, right-click the Lists of Tests folder and click Create New Test List.

    The Create New Test List dialog box appears.

  4. In the Name field, type BVTs as the name of the test list, and click OK.

    The BVTs list is created and displayed in the hierarchy pane of the Test Manager window under the Lists of Tests folder.

  5. Click the Tests Not in a List folder in the Test Manager window.

  6. Highlight DebitTest and CreditTest in the data pane of the Test Manager window. To do this, hold down the CTRL key while clicking both tests.

  7. With the tests highlighted, drag them into the BVTs list.

  8. Click the BVTs list in the hierarchy pane.

    This displays its contents, DebitTest and CreditTest, in the contents pane.

  9. Right-click the BVTs list in the hierarchy pane and click Create New Test List.

    The Create New Test List dialog box appears.

  10. In the Name field, type Bank as the name of the test list and click OK.

    The new test list is created and displayed in the hierarchy pane of the Test Manager window as a list under BVTs.

  11. Click All Loaded Tests in the hierarchy pane.

  12. Copy the DebitTest unit test into the Bank test list. To copy the test, while pressing the CTRL key, drag DebitTest into the Bank test list.

    A new instance of the DebitTest test is created and placed in the Bank test list.

  13. In the hierarchy pane, click All Tests.

  14. Right-click one instance of DebitTest and click Disable.

    Notice that both instances of DebitTest are disabled.

In this procedure, you created a new test list and added tests to it. You use test lists to group tests. In the past, to organize tests into groups so that you could run them together, you had to place them into directories and subdirectories on disk. To further segregate certain groupings of tests, such as those that test a specific software feature, you had to apply tags to the tests. Now you can use test lists for this purpose.

See Also

Tasks

Walkthrough: Creating and Running Unit Tests
Walkthrough: Using the Command-line Test Utility
Walkthrough: Run Tests and View Code Coverage

Other Resources

Managing Large Numbers of Tests