101 Ways to Run Tests with Visual Studio 2012
Posted
Sun, Sep 16 2012 13:59
by
Deborah Kurata
OK 101 is an exaggeration, but there are many ways to run your tests in Visual Studio 2012.
From the test code file
While you are writing or editing a test method, you can right click anywhere within the method and run or debug the test.

[Red rectangle added for illustration.]
All of the tests in Test Explorer are displayed "grayed out" except for the executed test as shown below. Click on the test to view the result details in the right pane (or bottom pane if your Test Explorer is sized to display vertically).

From the code editor, you can also run all of the tests within a code file by right-clicking anywhere within the code file, but outside of a specific method. Clicking in an empty space between two methods, for example, will execute all of the tests in the code file.
From Test Explorer Toolbar
View the Test Explorer window using Test | Windows | Test Explorer. The Test Explorer window toolbar provides many ways to run your tests.

- Run All
Runs all of the tests displayed in Test Explorer. If the list of tests are filtered by search criteria, only the filtered tests are executed. (See this prior blog post for information on searching within Test Explorer.) - Run Failed Tests
Runs only the failed tests displayed in Test Explorer. - Run Not Run Tests
Only runs the tests displayed in Test Explorer which were not previously run since opening Visual Studio. - Run Passed Tests
Runs only the passed tests displayed in Test Explorer. - Repeat Last Run
Runs the prior test run again, but only on the files displayed in Test Explorer. If you Run All then filter the tests in Test Explorer then Repeat Last Run, only the filtered tests will be executed again.
From Test Explorer Context Menu
Right-clicking on a test in Test Explorer provides run options.

You can select a single test, multiple tests using the Ctrl and Shift keys, or all tests using the Select All option from the context menu. Then you can Run or Debug the selected tests.
Use these techniques to run only the tests you are interested in.
Enjoy!