Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: Run all tests in a single project?

In my Visual Studio solution, I have about a dozen projects, several of which contain unit test methods (tagged with the TestMethod attribute), with several hundred test methods spread across those projects.

From within Visual Studio, I'd like to run all of the (100+) tests in one particular project in the solution, without running the tests in the other projects in the solution.

Ctrl+R, A doesn't do what I want, since that runs all tests in the entire solution. I also don't see any options to run tests in a particular project in the Test menu, in the Test Explorer window, or in the right-click context menu for a project in the Solution Explorer window.

I'm using Visual Studio 2013.

What's the best way to get Visual Studio to run all of the test methods in a particular project?

like image 354
Jon Schneider Avatar asked Nov 05 '15 16:11

Jon Schneider


People also ask

How do you run all tests in project?

To run all the tests in a solution, choose the Run All icon (or press Ctrl + R, V).

How do I run MSTest in Visual Studio?

In the new project dialog box, find the unit test project to use. Type test in the search box to find a unit test project template for the test framework you want to use, such as MSTest (C#) or the Native Unit Test project (C++), and select it. Starting in Visual Studio 2017 version 14.8, the .

Does TestInitialize run for each test?

TestInitialize and TestCleanup are ran before and after each test, this is to ensure that no tests are coupled. If you want to run methods before and after ALL tests, decorate relevant methods with the ClassInitialize and ClassCleanup attributes.


1 Answers

After some additional poking around the UI, I figured out a decent way to do this:

  1. Open the Test Explorer window. (Test menu > Windows > Test Explorer)
  2. Click on the little down arrow just to the left of the search field.
  3. From the context menu that appears, select Project. The Test Explorer window contents change to be grouped by project in a 2-tier hierarchy.

Test Explorer filter menu

  1. Right-click on the desired project.
  2. From the context menu that appears, click Run Selected Tests.

Test Explorer project context menu

I'd still like a reasonable way to do this with only the keyboard, though!

like image 163
Jon Schneider Avatar answered Sep 23 '22 23:09

Jon Schneider