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

18,657

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/

Share:
18,657
Rumi P.
Author by

Rumi P.

Updated on June 07, 2022

Comments

  • Rumi P.
    Rumi P. almost 2 years

    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.