Road To NUnit setup, test execution with a simple test script

NUnit:
Nunit is an open source unit testing framework for all .Net language

Setup NUnit: 
Download nunit exe from link: download
Install downloaded exe in your machine. your nunit GUI look like below screen when you open nunit

Steps to create First Test Scripts
  • Open Visual Studio or any IDE which support .Net framework.
  • Create new C# Project ( Library project)
  • Add nunit framework reference assembly to your created project, right click on project "reference" and then click on “Add References”
  • Go to opened popup window, navigate NUnit install directory ( NUnit 2.6.2\bin\framework) and add nunit.framework.dll file.
  • Add new class in your project like I created “MyTest.cs”
  • Add below code:
using NUnit.Framework;
using System;

namespace MyFirstTest
{    
    [TestFixture]
    public class MyTest
    {
        private string s1 = "NUnit";
      
        [Test]
        public void TestTrue()
        {
               //write your testing code
            Assert.IsTrue(s1.Equals("NUnit"));
        }

        [Test]
        public void TestFase()
        {
            //write your testing code
            Assert.IsFalse(s1.Equals("NUnit"));
        }
    }
}


Execution:
Build your project and Goto “File >>open project” and navigate bin>>debug directory of your project and open project dll file from open NUnit window.

Click on Run button you should see all test will executed 

No comments:

Post a Comment

Leave your comments, queries, suggestion I will try to provide solution