Chapter 8. NUnit

Overview

NUnit is a unit test framework for the Microsoft .NET architecture. Conceptually, it follows the xUnit model, serving as a foundation for building unit test classes and methods. It is implemented in C#, but supports writing unit tests in any .NET language, including C#, J#, Managed C++, and Microsoft Visual Basic .NET (VB.NET). NUnit defines tests using C# attributes rather than object inheritance, so the details of its software architecture differ significantly from JUnit.

NUnit is open source software released under a public license. The license permits NUnit to be freely redistributed and altered, as long as the original copyright notice is included and any alterations are acknowledged. The copyright holders and main developers of NUnit are James Newkirk, Michael Two, Alexei Vorontsov, Philip Craig, and Charlie Poole.

For additional information refer to the NUnit web site, http://www.nunit.org. The summary in this chapter is based on Version 2.1.

Architecture

NUnit is a full-featured unit test framework built using TDD. The distribution includes unit tests covering all of NUnit’s functionality. Aside from the core framework, NUnit also includes GUI and console test runners, code samples, extensions, and utilities.

NUnit relies on C# attributes to structure test code. In contrast to the conventional object-oriented definition of an attribute, a C# attribute is metadata attached to a code element such as a class or method. These attributes contain descriptive ...

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.