Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set test category for all tests in the class

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.

like image 286
alex Avatar asked Apr 04 '13 11:04

alex


People also ask

What is test category?

Test category means one type of test or group of tests specified by rule under sub. (4) for similar materials or classes of materials or which utilize similar methods or related methods.

What is test category in C#?

Effectively, using TestCategory lets you create a group of tests using any arbitrary system you want. This allows you to create (and run!) groups of tests that you feel are related without having to run every test in a class, a project or a solution.

What attribute do you use to categorize a test method or class?

TestCategory attribute; used to specify the category of a unit test.


1 Answers

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/

like image 119
NomadeNumerique Avatar answered Sep 19 '22 16:09

NomadeNumerique