This is the “Fundamentals of unit testing” article series. In our previous article we saw various concepts of unit testing, you can read them here.
- Fundamentals of Unit Testing: Getting Started With Unit Testing
- Fundamentals of Unit Testing: Test Your Application by Visual Studio Unit Test
- Fundamentals of Unit Testing: Understand AAA in Unit Testing
- Fundamental of Unit Testing: Understand AreEqual and AreEqual<T> in Unit Testing
- Fundamental of Unit Testing: Test Initialize and Test Setup
- Fundamentals of Unit Testing: Understand CollectionAssert() in Unit Testing
- Fundamentals of Unit Testing: Understand ExpectedException in Unit Testing
- Fundamentals of Unit Testing: Don't Test Your Private Method
In our previous articles we have implemented unit testing in Visual Studio's built-in unit test application project, but in this article we will use the Nunit framework to implement the unit test. The Nunit framework is very popular and simple to use.
So, to use Nunit framework, we need to install it in our system. Go to the following URL and download the Nunit framework. There are many download options. I have chosen .msi because I am using Windows and wanted to install using a direct installer file.

Once you have finished the installation you will find Nunit application in your All program menu. Fine, now we will create a class library application that we will implement as the unit test application using Nunit and one more class library application that we will test using Nunit test.
So, let's create the class library and make it the unit test application.

I have used the name N-Unit for the application. Just click OK to create it. Now, we will install the Nunit framework to this project from the Nuget package manager.

Once installed, you can provide reference of the “nunit.framework” library in the application, now the application will behave as a unit test application.

Ok, fine; let's write a class to implement the unit test. Here is the sample class that will test a calculator class that we will implement shortly.




Karabo SepoloanePosted Oct 24, 2018, 4:36 AM
Fundamental of Unit Testing: Test Initialize and Test Setup: The link is brocken redirects back to Assert.AreEqualt
Nitin AnandPosted Jan 31, 2017, 7:24 AM
Now, one can perform NUnit test even within VS Test Explorer as you showed in earlier articles, MSTest. Need to download NUnit and NUnit3Adapter from NUGet PM to the Test Project.
Jaipal ReddyPosted Apr 20, 2016, 7:26 AM
Nice.
Gowtham RajamanickamPosted Apr 25, 2015, 5:29 AM
good