NUnit

NUnit

NUnit 2.4.6 GUI on Windows
Stable release 2.5.10 / April 2, 2011; 10 months ago (2011-04-02)
Written in C#
Operating system Microsoft .NET, Mono
Type Unit testing tool
License BSD-style (modified zlib license)
Website www.nunit.org

NUnit is an open source unit testing framework for Microsoft .NET. It serves the same purpose as JUnit does in the Java world, and is one of many in the xUnit family.

Contents

Features

Every test can be added to one or more categories, to allow running them selectively.[1]

Example

Example of an NUnit test fixture:

using NUnit.Framework;
 
 [TestFixture]
 public class ExampleTestOfNUnit
 {
   [Test]
   public void TestMultiplication()
   {
     Assert.AreEqual(4, 2*2, "Multiplication");
 
     // Equivalently, since version 2.4 NUnit offers a new and
     // more intuitive assertion syntax based on constraint objects
     // [http://www.nunit.org/index.php?p=constraintModel&r=2.4.7]:
     Assert.That(2*2, Is.EqualTo(4), "Multiplication constraint-based");
   }
 }

The NUnit framework discovers the method ExampleTestOfNUnit.TestMultiplication() automatically by reflection.

Extensions

FireBenchmarks[2] is an addin able to record execution time of unit tests and generate XML, CSV, XHTML performances reports with charts and history tracking. Its main purpose is to enable a developer or a team that work with an agile methodology to integrate performance metrics and analysis into the unit testing environment, to easily control and monitor the evolution of a software system in terms of algorithmic complexity and system resources load.

NUnit.Forms is an expansion to the core NUnit framework and is also open source. It specifically looks at expanding NUnit to be able to handle testing user interface elements in Windows Forms. As of August 2010, Nunit.Forms is in Alpha release, and no versions have been released since May 2006.

NUnit.ASP is a discontinued[3] expansion to the core NUnit framework and is also open source. It specifically looks at expanding NUnit to be able to handle testing user interface elements in ASP.NET.

See also

References

Further reading

External links