Overview of Nunit Testing Framework

what is the Nunit ?

If you are new to Nunit, please go through this post How to configure Nunit in Visual Studio

It is the unit test case framework based on .Net Framework. Which is widely used by .net developer to write the unit test case. It is open source and free to use by any person. You don’t have to pay any money for this tool.

why should we use Nunit framework instead of MS-UnitTest Framework ?

These are the few important point to use Nunit instead of MS-Test

1. It is matured and stable unit test case framework
2. It gives good performance as compare to MS-Test
3. It has good community support
4. It is the popular Open Source project
5. Suite attribute - can aggregate tests and execute them separately. It will be useful for large projects.
6. NUnit has frequent version updates - MS-Test has only one per VS version.
7. It takes less memory to execute the test case as compare to MS-Test.

what are the important attributes of Nunit Framework?

There are following important attributes of NUnit Framework
a> TestFixtureAttribute

>>It is used to indicate the class which contains the test method.

b> Description

>> as the name suggest, it gives the description of class or test method

using System;
  using NUnit.Framework;

  [TestFixture, Description("Fixture description here")]
  public class SomeTests
    [Test, Description("Test description here")] 
    public void TestMethod()
    { /* ... */ }

c. SetUP
>> It is generally used for declaration of object before running the unit test case.

d. TearDown : It is generally used for cleaning the object at end of the test case.

d. Test : This attribute generally keep on top of method name. It is used for writing the unit test case related code for check the expected functionality of application.

using System;
  using NUnit.Framework;

  public class SuccessTests
    public void Init()
    { /* ... */ }

     public void Cleanup()
    { /* ... */ }

    public void Add()
    { /* ...... */ }

There are so many other attribute available in Nunit. If you are looking to learn more about it. Please check the below URL

Nunit Attributes document URL


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s