Setting Up a test environment in Visual Studio 2015

Test run on Visual Studio 2015 and NUnit 3

Setting up NUnit 3 in Visual Studio is a simple task, but if you don’t know what you need to do, there are a few ways you can easily get stuck. To help you avoid losing time I put together all the steps you need to follow to get you up and running.

The steps to setup Visual Studio are the following:

  1. Open Visual Studio 2015
  2. In the menu bar go to Tools > Extensions and Updates
  3. On the sidebar select Online and then type nunit on the search bar
  4. Install NUnit Templates for Visual Studio
  5. Install NUnit3 Test Adapter
  6. Restart

OK, now your system is ready. Let’s add a test project to your solution

  1. Open your solution
  2. In the menu bar go to File > Add > New Project…
  3. On the sidebar select Installed > Visual C# > Test
  4. On the main panel select NUnit 3 Unit Test Project and choose a proper name (like UnitTests)
  5. In the new project you wil find a file named TestClass.cs, open it
  6. In the menu bar go to Test > Run > All Tests

The last step will build and run all the tests in your solution (1 for now). A window with the test results should popup, otherwise go to Test > Windows > Test Explorer to bring it up.

The test should pass and be marked as green. Otherwise write a comment to this post and I’ll help you solve this problem.

The following video shows all the steps you need to follow

p.s. I know that Visual Studio 2015 comes pre-built with it’s own environment for test based on MSTest, but I highly recommend using NUnit, since it is better and is what most people use. So please, follow this guide.

 

Advertisements

One thought on “Setting Up a test environment in Visual Studio 2015

  1. Pingback: Why I don’t unit test? | Code cleaners

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s