Share via


Right-Click Test Execution

One of the great new features of Visual Studio 2008 is the ability to run your unit tests from the context of a test method or a test class. This feature is known as right-click execution and provides a mouse-based complement to keyboard shortcuts for running a single test method or all the test methods in a test class or test assembly.

When working with unit tests it is often useful to be able to run the current test method or all tests in the current test class. This can be accomplished via the new Run Tests menu option on the unit test context menu (Fig. 1). As you can see, the Run Tests menu option sits at the top of the unit test context menu, below the refactoring options. Clicking this menu option will execute your tests in the current scope—where you are in your test project. For example, if you right-click inside a test method, Run Tests will run just that test method. If you right-click inside a test class, but not inside an actual test method—i.e. a method with the TestMethodAttribute attribute—Run Tests will run all the tests in the test class. Last but not least, if you right-click inside a test project but neither inside a test method nor inside a test class, Run Tests will run all tests in the test project.

Figure 1: Unit Test Context Menu

Comments