Test Driven Development using NUnit

Thursday, July 30, 2009

Introduction


NUnit is a free, open-source tool for .NET that is developed as a framework which can help automate unit testing. (The same unit test framework was already available for Java and was named jUnit.)


NUnit can be downloaded from NUnit site or the SourceForge NUnit page.


Installation and Setup of NUnit


After downloading the NUnit from either of the above download pages, run the installation program, NUnit-XXX.msi. At the time of this writing, the current version of NUnit is 2.2.0 and the setup file name is NUnit-2.2.0.msi. This setup will install the required libraries.

NUnit provides two utilities which can be used for running automated tests:

1. nunit-gui.exe, a GUI tool which I most commonly use, and

2. nunit-console.exe, which is a console program

Once you have installed NUnit you can test if the installation has gone through properly using the nunit-gui.exe tool.

This can be run from Start Menu --> Programs --> Nunit --> NUnit GUI.

After opening the tool, click on the File --> Open and open the nunit.tests.dll from the C:\Program Files\NUnit 2.2\bin folder. (The folder could be different if the installation has happened by choosing a different folder.)

When the DLL is chosen, NUnit-GUI shows all the unit test code written for the particular DLL using the NUnit framework.

If the button Run is clicked, it will show the results as follows.

• Passed Test - Green color

• Failed Test - Red color

• Ignored Test - Yellow color

The nunit.tests.dll DLL contains over 600 tests and when run all of them should pass and turn the color to Green.

For more details, visit http://www.nunit.org/index.php?p=home

0 comments:

Post a Comment

 
 
 
Your Ad Here