Over ten years ago, I started testing my code with NUnit. At the time it did not have two of the features I will review today, parameterized testing and Visual Studio integration. Because of this I had switched to MSTest for most of my recent projects. I am now going to use NUnit in my new projects.
At the time of this writing, there are some unfortunate version issues you must be aware of. Visual Studio integration will only work with NUnit version 2.4.6. The latest version is currently 3.0.1. This is because of another package called, NUnitTestAdapter. That package gives Visual Studio the ability to populate the Test Explorer tab showing the test results.
Visual Studio Integration
With the NUnitTestAdapter installed the test methods will now show in the Test Explorer tab in Visual Studio.
Parameterized Unit Tests
Below is some sample code showing a regular Unit Test compared with a parameterized Unit Test. With this feature you can test multiple parameters in one test using attributes on the method parameters. If you had more then one parameter you would add an attribute for each one.
If you found this article helpful, use the tweet button below to spread the word. Thank you.