NUnit

From Wikipedia, the free encyclopedia
Jump to: navigation, search
NUnit
NUnit Logo 2013.gif
NUnit GUI.png
NUnit 2.4.6 GUI on Windows
Stable release 2.6.3 / October 10, 2013; 13 months ago (2013-10-10)
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 programs in the xUnit family.

Features[edit]

Every test case can be added to one or more categories, to allow for selective running.[1]

Example[edit]

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[edit]

FireBenchmarks 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 January 2013, Nunit.Forms is in Alpha release, and no versions have been released since May 2006.

NUnit.ASP is a discontinued[2] 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[edit]

References[edit]

  1. ^ "CategoryAttribute - NUnit documentation". Retrieved 2008-04-15. 
  2. ^ "NUnit.ASP website main page". Sourceforge. Retrieved 2008-04-15. 

Further reading[edit]

  • Andrew Hunt, David Thomas: Pragmatic Unit Testing in C# with NUnit, 2nd Ed. The Pragmatic Bookshelf, Raleigh 2007, ISBN 0-9776166-7-3
  • Jim Newkirk, Alexei Vorontsov: Test-Driven Development in Microsoft .NET. Microsoft Press, Redmond 2004, ISBN 0-7356-1948-4
  • Bill Hamilton: NUnit Pocket Reference. O'Reilly, Cambridge 2004, ISBN 0-596-00739-6

External links[edit]