Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Visual Studio Test, how to make a playlist which automatically excludes certain tests?

Our team has Visual Studio 2012 Professional licenses (not Test Professional). We are developing a smallish web application, and we have both true unit tests which mock everything needed, and tests for the data layer. Each class of data layer tests creates the whole database from scratch and fills it with a prepared set of test data, so running them takes a long time. As a result, we are reluctant to do a "run all", and our unit tests (which are quick) are only used rarely.

We are looking for a low-friction solution which will allow us to run all quick tests with 2-3 clicks (similar to the existing Run all) frequently, and easily run all tests when needed.

We tried making a playlist of the quick tests only. But we are done with programming the data layer, so practically all new tests we write are quick tests, and adding each of them to the playlist is annoying and somewhat error-prone. We would prefer an approach where we somehow mark the tests we do not want in a "quick run" as excluded, and it automatically runs all other tests in the solution. Note that we don't want to permanently add an Ignore attribute to the slow tests, as we still want to run them at least once daily.

like image 747
Rumi P. Avatar asked Oct 10 '13 11:10

Rumi P.


People also ask

How do I create a test playlist in Visual Studio?

To create a playlist, choose one or more tests in Test Explorer. Right-click and choose Add to Playlist > New playlist. To open a playlist, choose the playlist icon in the Visual Studio toolbar and select a previously saved playlist file from the menu.

How do I ignore a test in Visual Studio?

If you want to enable or disable unit tests in Microsoft Visual Studio 2010, you can use the “Ignore” attribute. This can be used to ignore ore exclude integration tests in a nightly continuous integration build.

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

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


1 Answers

You could use the Traits feature in mstest to accomplish this. Take a look at this blog post: https://devblogs.microsoft.com/devops/how-to-manage-unit-tests-in-visual-studio-2012-update-1-part-1using-traits-in-the-unit-test-explorer/

like image 163
Jocke Avatar answered Sep 18 '22 03:09

Jocke