What Is NUnit?

NUnit is an easy-to-learn, open source framework built using Visual Studio .NET 2003 and the .NET Framework 1.1. NUnit automates unit tests for all .NET languages.

NUnit facilitates unit testing by providing a framework to support test development and test runners to run the tests and assess their results. NUnit includes test runner executables with both GUI and command-line interfaces. The command-line interface is particularly useful for automated build and test environments.

NUnit tests are easily repeatable by anyone with access to the code and test assemblies. This allows you to test the impact of your changes on the work of the entire development team in a distributed development environment. Verifying your code against the entire project maintains the integrity of the overall build.

How Does NUnit Work?

The NUnit framework provides a collection of base classes and attributes to support unit testing. Unit testing code is organized into tests, test fixtures, and test suites, as described in "Setting Up NUnit."

.NET reflection lets you dynamically examine and modify code at runtime. Reflection queries metadata in the portable executable (PE) file (i.e., a DLL or EXE) using services in the System.Reflection namespace. The Common Language Runtime (CLR) allows you to add descriptive declarations called attributes to annotate programming elements, such as methods, fields, properties, and types. These attributes are saved with the metadata. Attributes are used both to describe ...

Get NUnit Pocket Reference 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.