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?

2 Answers 2


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)

  • Thanks. Do you know if it is possible to filter by test category on the search box?
    – oillio
    Sep 9, 2012 at 17:04
  • 2
    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, 2012 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. Mar 15, 2016 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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