Friday, July 1, 2011

NUnit: The Very First Test Project

Goal: To run the simplest C# test cases created in NUnit

Setup: Visual Studio C# 2010 Express, and NUnit 2.5.10 (If you don’t have these installed follow the installation process here)

Steps:
  1. Create the Test Project
    i)    Open Visual Studio
    ii)    Create New Project using template ‘NUnit Test Application’ and rename it if you want
    iii)   The project will be created and the solution explorer will look like this 
    iv)   If you open the file ‘TestFixture.cs’ sample test cases have already been created for you containing a test case which will Pass and another that will Fail
    v)    Go ahead and build this solution by clicking Debug > Build (hit CTRL + SHFT + B)
  2. Run the Test Project
    i)    Open Nunit and click File > Open Project
    ii)    Browse to the .dll or .exe file for the .NET project we have created in step 1 (My location: (C:\Users\QA Computer\Documents\Visual Studio 2010\Projects\NUnitTest1\NUnitTest1\NUnitTest1\bin\Release)
    iii)   The tests will open in the Test explorer at left.
    iv)   Simply click the Run button to run all tests an examine the results
If you are among the unlucky ones who run into a CLR version related error while opening project in NUnit, follow the steps here to fix it.

1 comment: