How to unit test in Visual Studio 2019

ZeroesAndOnes
8 min readMay 15, 2020

The Microsoft unit test framework is installed with Visual Studio and provides a framework for testing .NET code. In this article I will walk you through step-by-step showing you hot to properly create a unit test project and write a unit test to test a specific unit of work in an MVC project.

1 — Create a Unit Test project

To create a new Unit Test project and associate it with your solution the first thing that you must do is right click at the root level of the solution in the Solution Explorer panel. Then find the “Add” option from the context menu and in the sub-menu find the “New Project” option and click on it.

The “Add a new project” window will appear in Visual Studio. On that screen, you can scroll down through the list to find the “Unit Test Project (.NET Framework)” and then click the “Next” button.

Additionally, you can filter down the list of projects by project types and choose the “Test” option which will only show projects that are of type test. This can speed up your search process instead of having to scroll down through the list.

--

--