共用方式為


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.

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.

See Also

Other Resources

Creating Automated Tests