Skip to main content
Version: 8.2

NUnit

Level: advanced

Unit testing (module testing) is a software development process that lets you verify the operation capacity of isolated program components. Usually, developers write tests for each non-trivial method of a developed class. This lets you detect source code regression: errors in previously tested parts of the program.

One of the unit testing frameworks for .NET apps is NUnit, an open-source unit testing environment. A special adapter was developed to integrate NUnit with Visual Studio.

You can install the adapter in the following ways:

  • as Visual Studio extension
  • as NuGet project package that contains the implemented unit tests

Use of the NUnit adapter as a Visual Studio extension has the following special features:

  • The adapter is available for any test project since the adapter becomes part of the IDE.
  • The extension is updated automatically.
  • Each team member who works on the test project must install a separate adapter.

Use of the NUnit as a NuGet package has the following special features:

  • The package is a part of the Visual Studio project and available for all project developers.
  • The package must be installed for all unit test projects.

Learn more about working with NUnit: official vendor documentation (NUnit).

To create unit tests for user-made package class methods or properties:

  1. Install NUnit Visual Studio adapter.
  2. Turn on the file system development mode.
  3. Set up the unit test project.
  4. Create tests.
  5. Test the methods or properties.

Resources

Module testing (Wikipedia)

Official NUnit website

Official NUnit documentation