Exploring and Managing Unit Tests Using Test Explorer in Visual Studio

Exploring and Managing Unit Tests Using Test Explorer in Visual Studio

In the previous post you have learned how to get started with Unit Test in Visual Studio (How to write your very first Unit Test in Visual Studio using MSTest Framework easily ?) . Now it’s the time to manage the explore your Unit Tests in Visual Studio. The objective of the Test Explorer is to quickly access to test methods and execute then efficiently and as and when they are required. Once solution is build, all the test methods discovered automatically by the Visual Studio and listed in Test Explorer in “Not Run Tests” status. Then onwards, based of the execution status of the test method, the indication / status of methods change.

To open the Test Explorer , Navigate to  Test –>  Windows –>  Test Explorer from the main menu.

image

If your solution has not build yet and you open the Test Explorer, it will display a message as below to ask build the solution so the Visual Studio can discover the test methods. Then only you would be able to execute them.

image

Once you build the solution, Test Explorer will list out all the test methods with “Not Run Tests” group.

image

From here you can “Run All” or Run specific test method / run selected test methods.

image

Once the execution is completed, all the test method status ( Passed, Failed, Skipped etc.) would be updated in the list and you can group them to view in different category.

image image

By selecting the failed test cased, the test explorer can also display the error/ failed reasons of the test cases.

image

The Test Explorer also gives the provision of Run specific test cases like Failed Test, Not Run Test Cases etc. You can explore this list of options, they are very straight forward and easy to run.

image

Test explorer also support search specific test method – with in class, files , etc. and group by based on duration, outcomes, project etc. The image below shows the same.

image

Hope this help.

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.