Using NUnit’s TestCase Attribute

In the last post, we setup an NUnit test project and ran it in Visual Studio. In this post we are going to expand on that code to add more unit tests using the NUnit TestCase attribute.

Looking back at the last post, we are testing a method that converts an enum value to a friendly string by splitting the enum name at capitals. In that post, we only tested with one enum value. In this post, we will test with multiple enum values to ensure that the method handles every type of input. We will then remove code duplication by using the [TestCase] attribute to run one test many times with different data. (more…)

Read more

Introduction to Unit Tests with NUnit

You have a new project and you want to add unit tests, where do you start?  This tutorial walks you through adding an NUnit test project, writing your first tests and running them in Visual Studio.

This walk-through assumes you already have a project that you want to test. I am starting here with a project that contains a simple class that contains an extension method that converts an enum value to a friendly string by splitting the enum name at capitals. For example, System.Windows.Forms.Keys.BrowserBack would become “Browser Back”. (more…)

Read more