Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Visual Studio 2012 has a new feature where it automatically runs your unit tests after every build.

I would like to use this feature, but I have a number of tests that should not be run after every build (long running performance tests, etc).

Is there a way to define which categories are run automatically? Or some other way to define which test should be run?

share|improve this question
up vote 5 down vote accepted

A colleague of mine wanted to know the answer to this question also.

He asked Cathy Sullivan (A Microsoft Visual Studio Program manager) on Twitter whether it was possible.

Cathy came back and said that unfortunately, it's not possible, however as part of the same conversation, Joshua Weber (another MS VS Program Manager) stated that Visual Studio's "Run Tests On Build" will honor any current filter you've applied within the search box.

(Image grab of twitter conversation)

share|improve this answer
Thanks. Do you know if it is possible to filter by test category on the search box? – oillio Sep 9 '12 at 17:04
If anyone is interested, this is how I am making this work: I couldn't find any way to filter by category. The best I found was the FullName filter, which will filter for any string in the namespace, class, or method name. I am adding the text "AutoRun" to the class name of all the tests I want to run continuously. In the Test Explorer, I search for: FullName:"AutoRun". Then the "Run Tests After Build" feature works perfect. – oillio Sep 10 '12 at 16:26
You can filter by category. They're called "Traits" For instance, if you want to run all tests marked with category "fast", type: "Trait:fast". If you want to run all tests NOT marked with category "slow", type "-Trait:slow". No quotes. – zumalifeguard Mar 15 at 18:49

After update 1, you can filter on categories in the search box using the trait filter. See this blog post for more info.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.