Defining Test Categories to Group Your Tests
If you have created automated tests using Visual Studio you can manage these tests by categorizing them with test categories. When you run these automated tests using Visual Studio, Team Foundation Build, or mstest.exe, you can use these test categories to easily select which tests you run. You add test categories as attributes to your test methods.
Requirements
- Visual Studio Ultimate, Visual Studio Premium, Visual Studio Test Professional
Test categories provide more flexibility than the test lists functionality from earlier versions of Microsoft Visual Studio. You can use logical operators with test categories to run tests from multiple categories together or to limit the tests that you run to tests that belong to multiple categories. Also test categories are easy to add as you create your test methods and you do not have to maintain test lists after you have created your test methods. By using test categories, you do not have to check in and check out the <solution name>.vsmdi file that maintains the test lists.
Warning
Test lists are no longer fully supported in Visual Studio 2012:
-
You can’t create new test lists.
-
You can’t run test list tests from within Visual Studio.
-
If you upgraded from Visual Studio 2010, and had a test list in your solution, you can continue to edit it in Visual Studio.
-
You can continue to run a test list using mstest.exe from the command line. For more information, see How to: Run Automated Tests from the Command Line Using MSTest.
-
If you were using a test list in your build definition, you can continue to use it. For more information, see How to: Configure and Run Scheduled Tests After Building Your Application and Run Tests in Your Build Process.
Tasks
Tasks |
Associated Topics |
---|---|
Grouping Tests into Test Categories: You can add an automated test to one or multiple test categories using a test attribute. Each test can belong to multiple test categories. |
|
Running Tests Using Test Categories: After you choose which tests you want to run, you can choose which test categories they must belong to. You do this by using logical operators. For example, you could run all tests that belong to Priority 1 test category and Priority 2 test category. |
|
Using Test Categories To Select Tests to Run Before Check-In: You can use a build to check your code changes before you check in. You can use test categories to define the tests to run for this gated check-in build. |
|
Using Test Categories To Select Tests to Run After Building Your Application or Before Check-In: You can use a build definition to define which test categories to run to test a new build. |