NUnit
From Wikipedia, the free encyclopedia
NUnit 2.4.6 GUI on Windows |
|
Latest release | 2.4.8 / 2008-7-21 |
---|---|
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
- ^ "CategoryAttribute - NUnit documentation". http://nunit.org/index.php?p=category&r=2.4.7. Retrieved on 2008-04-15.
- ^ "NUnit.ASP website main page". Sourceforge. http://nunitasp.sourceforge.net/. Retrieved on 2008-04-15.
[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
- NUnit home page
- SourceForge Site
- Test-driven Development with NUnit & Test-driven.NET video demonstration
- NUnit.Forms home page
- NUnitAsp homepage
- Article Improving Application Quality Using Test-Driven Development provides an introduction to TDD with concrete examples using Nunit