One way to run automated tests is to use Visual Studio’s Test Explorer. Test Explorer can be found under the Test –> Windows –> Test Explorer menu items.
In this article we’ll look at how to manage the list of tests using grouping and also how to specify custom search filter expressions.
![Two test projects in Visual Studio solution Two test projects in Visual Studio solution](/blog/image.axd?picture=image_66.png)
Grouping Tests
There are a number of ways to group tests in Test Explorer, at the highest structural level we can group by project.
To select a group by method, click the drop down arrow as show in the following screenshot:
![Selecting a grouping in Visual Studio Test Explorer Selecting a grouping in Visual Studio Test Explorer](/blog/image.axd?picture=image_67.png)
With the grouping set to Project, the test list looks as follows:
![image image](/blog/image.axd?picture=image_68.png)
The next structural grouping is Class:
![Grouping by test class Grouping by test class](/blog/image.axd?picture=image_69.png)
The final structural grouping is by Namespace:
![Grouping by namespace Grouping by namespace](/blog/image.axd?picture=image_70.png)
There are a number of non-structural groupings.
Group by Duration:
![Group by duration Group by duration](/blog/image.axd?picture=image_71.png)
Group by Outcome:
![Group by outcome Group by outcome](/blog/image.axd?picture=image_72.png)
…and group by Traits:
![Grouping by traits Grouping by traits](/blog/image.axd?picture=image_73.png)
Filtering Tests
Custom filters can also be applied.
For example by file path:
![Filtering tests by file path Filtering tests by file path](/blog/image.axd?picture=image_74.png)
Other search examples include:
- Trait:"Smoke Test"
- Message:"System.Exception"
- Class1
- Outcome:"Passed"
- Outcome:"Failed"
Subsets can also be excluded by prefixing the type of filter with a -. For example to show all tests in Class1 except failed tests: Class:"TestClass1" -Outcome:"Passed".
To learn xUnit.net check out my xUnit.net course from Pluralsight - You can start watching with a Pluralsight free trial.
![](//a.impactradius-go.com/display-ad/7490-1161404)
![](https://pluralsight.pxf.io/i/1392775/1161404/7490)
SHARE: