Pages

Monday, August 15, 2011

NUNIT for Asp.net

NUnit is a unit-testing framework for all .Net languages.

Official website for NUNIT :- http://www.nunit.org


Installation Step:-

1) In order to include Nunit template in our Visual Studio, download Nunit template from
http://www.dalsoft.co.uk/blog/index.php/2009/11/17/nunit-templates-for-asp-net-mvc-2-0-preview-2/ and Install it.

2) Download Nunit GUI from http://www.nunit.org/index.php?p=download and install it.

Following are the step to create Nunit Test project:-

  • For adding a Nunit test for existing application, right click on the class for which Nunit test need to be create. Click on the create unit test. A pop up will be open which will give two option in dropdown for selecting template. Select Nunit template.

  • Class will be created in separate solution for Nunit test purpose

  • Class will have an attribute [TextFixture] which specify that class is used for Nunit testing purpose

  • All methods under same class will have attributes [Test] which define the particular method is for Nunit test purpose

  • In order to do testing with Nunit GUI, Nunit GUI interface need to be install.

  • After successfully installation of Nunit GUI, open project in Nunit GUI interface (File->Open Project->) by giving path to interface.

  • Nunit interface will show all the test methods on left hand side. To test the method right click on it and run, it will show green progress bar if successful and red in case of failure.


Steps to Install NUNIT



Steps to RUN Test Cases


  • Open the NUNIT tool and give the path of your testing solution (File>OpenProduct)
  • In order to test any class or method select that particular class or method then right click to run.
  • If the selected node icon change to green, code pass the test successfully and if change to red it fails.
How do I run NUnit in debug mode from Visual Studio?

When I need to debug my NUnit tests, I simply attach to the NUnit GUI application using "Debug|Attach to Process" and run the tests from the GUI. Any breakpoints in my tests (or the code they're testing) are hit. Am I misunderstanding your question, or will that work for you?

4 comments: