Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012 RC - Run Unit Tests after build - Specify test categories to run

In VS2012 (RC, soon to be RTM) is it possible to be selective about the (nunit) unit tests that run after every build? I love this feature, but I have two test categories/assemblies - one for actual unit tests that are expected to run quickly, another for database scheme and test generation data. I do not want to run the latter after every build, though I'd like to make use of this functionality for regular unit tests. Is there any way of specifying categories/assemblies/etc. that should be executed upon a successful build? Thanks JP

like image 396
JP. Avatar asked Aug 02 '12 18:08

JP.


People also ask

How do I run a specific unit test in Visual Studio?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.

How do I debug a single unit test in Visual Studio?

To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.

How do I stop a test case from running in Visual Studio?

You need to close the Test Explorer Window to prevent automatic running.


2 Answers

On the test explorer window, there is a searchbox. You can specify filters - one that looks promising is called a TestFilePath filter. (Dropdown to see available filters)

e.g. FilePath:"Transaction" filters only the tests in the Transactions.cs file. You can use this to exclude the tests in the other assembly e.g. if the folder is Unit and Database. Specifying FilePath:"Unit" should work. Give it a try..

Docs: Search for "filtering" on the page here

like image 38
Gishu Avatar answered Oct 11 '22 23:10

Gishu


@Gishu is correct. If you apply a filter to the Test Explorer, the runner will use the results of that filter list when choosing tests to run.

We will be continuing to add additional filter choices (e.g. Categories, Project, etc.) to the Test Explorer through and post-RTM. Stay tuned for more on this.

like image 143
Peter Provost Avatar answered Oct 11 '22 23:10

Peter Provost