NUnit

From Wikipedia, the free encyclopedia

Jump to: navigation, search
NUnit

NUnit 2.4.6 GUI on Windows
Latest release 2.4.8 / 2008-7-21; 250 days ago
Written in C#
OS Microsoft .NET and Mono
Type Unit testing tool
License BSD-style
Website http://www.nunit.com/

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

[edit] Features

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


[edit] Example

Example of an NUnit test fixture:

using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
 
 [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 constraint-based assertion 
     // syntax: http://www.nunit.org/index.php?p=constraintModel&r=2.4.7
     Assert.That(4, Is.EqualTo(2*2), "Multiplication constraint-based");
   }
 }

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

[edit] Extensions

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 February 2008, 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.

[edit] See also

[edit] References

[edit] Further reading

  • 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

[edit] External links

Personal tools