Visual Studio Quick Tip: Only unit tests in Test Explorer

My team recently consolidated several test projects which resulted in both unit and integration tests in the same project.  Unfortunately some of our integration tests rely on resources not available locally so they fail:

image

Thankfully Visual Studio allows you to filter your tests in the Test Explorer.  There are many options but its positive matching only (“not equal to” isn’t an option).

image

But it does support partial name matching so you can match on part of the namespace.  For example, if you have your unit tests in a “Unit” folder you can use the filter value –

FullName:”.unit”

image

The bar at the top still shows red because I previously ran all tests and the integration tests were failing.  If I click “Run All” again it will only execute the unit tests.

image

Happy Testing!

Leave a Reply