I've switched to using VS 2012 and for most parts it is great. The problem is I can't find how to filter my unit test by category?
Tests can be run from Test Explorer by right-clicking in the code editor on a test and selecting Run test or by using the default Test Explorer shortcuts in Visual Studio.
To generate unit tests, your types must be public. Open your solution in Visual Studio and then open the class file that has methods you want to test. Right-click on a method and choose Run IntelliTest to generate unit tests for the code in your method. IntelliTest runs your code many times with different inputs.
Starting in Visual Studio 2022 Update 2, you can enable faster code coverage test results by selecting Tools > Options > Environment > Preview Features, then selecting Code coverage experience improvements, and then restarting Visual Studio.
Assuming you have used the TestCategoryAttribute like this:
[TestMethod, TestCategory("MyTestCategory")]
public void MyTest() {}
In the Test Explorer window, to include a particular category, type this in the filter text box:
Trait:"MyTestCategory"
To remove tests of a particular category, type this in the filter text box:-Trait:"MyTestCategory"
You can filter out or include multiple categories. This allows you to filter out integration tests and automated UI tests in the Test Explorer window so that you can use the "Run Tests After Build" more effectively.
See here for more: http://msdn.microsoft.com/en-us/library/hh270865.aspx#BKMK_Searching_and_filtering_the_test_list
In the most recent Visual Studio 2012 CTP this feature has been added. The Test Explorer now has the option to group tests by traits (categories) and to filter by traits (categories) https://msdn.microsoft.com/en-us/library/hh270865.aspx
I too have been looking for this feature and as far as I can tell you can't filter by Category. I tried using a search filter Category:"categoryName", but that didn't work. It appears you can run by test categories from the command line (http://msdn.microsoft.com/en-us/library/dd286683.aspx), and you can define which categories to run in a build (http://msdn.microsoft.com/en-us/library/dd286595.aspx), but it does not appear possible from the IDE.
I was hoping to try out the default test tools of Visual Studio 2012, but with the reliance I have on test categories, the only option appears to be 3rd party commercial tools, such as JetBrains dotCover.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With