How to set test category for all tests in the class

alex picture alex · Apr 4, 2013 · Viewed 18.7k times · Source

I am using MSTest, and I want to set the same test category for all methods in test class at once, without setting TestCategory attribute to each method individually. How can this be done?

The most convenient and obvious way would be to set TestCategory attribute on class, but it can be applied to methods only.

The ultimate goal is to skip integration tests during test run on TFS check-in.

Answer

NomadeNumerique picture NomadeNumerique · Jun 14, 2018

To be able to set the [TestCategory] attribute at the class level, install the “MSTest V2” TestFramework using NuGet.

Ref: https://blogs.msdn.microsoft.com/devops/2016/06/17/taking-the-mstest-framework-forward-with-mstest-v2/