Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a test category from the Visual Studio UI

I have a set of unit test , marked with category attribute like so:

[TestCategory("Bugs"), TestMethod]

I can run the tests from the console as described here http://msdn.microsoft.com/en-us/library/dd286683.aspx.

And I Run them locally using post build events when needed, Is there a way to integrate the TestCategory Into the visual studio Test Explorer?

like image 551
Shachaf.Gortler Avatar asked Aug 19 '14 11:08

Shachaf.Gortler


People also ask

How do I run a test class in Visual Studio?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.

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.


2 Answers

In your Test Explorer, right click and select "Group by -> Traits".

enter image description here

MSDN

like image 96
Jeroen Vannevel Avatar answered Sep 20 '22 14:09

Jeroen Vannevel


If all you want to do is group them, click on the icon to the right of the "Run Tests After Build" icon and select "Traits". You'll see them sorted by TestCategories.

Update: Confirmed that this also works for VS2012 (in addition to VS2013)

like image 44
The Unisphere Avatar answered Sep 18 '22 14:09

The Unisphere