CheckOps home

Tools directory

N

CheckOps

NUnit

NUnit is an MIT-licensed unit-testing framework for all .NET languages on Windows, macOS and Linux, broad and non-opinionated, now at version 5 after NUnit 3 and 4.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

Introduction

NUnit is a unit-testing framework for all .NET languages, running on macOS, Linux and Windows. Its README describes it as non-opinionated, broad and deep, with multiple ways to assert that code behaves as expected and many extension points. It can be used for everything from unit testing with TDD to full system and integration testing.

NUnit started as a port of JUnit in the early 2000s and has been rewritten several times since. The current major version, NUnit 5, is described as an upgrade from NUnit 3 and 4, modernised to take advantage of the latest .NET features and C# language constructs. Version 5.0.0 was released on 27 September 2026, and the README links migration guides and breaking-change notes for teams coming from NUnit 3 or 4.

NUnit’s constraint-based assertion model, Assert.That(actual, Is.EqualTo(expected)), is one of its signatures. Constraints compose (Is.Not.Null.And.Not.Empty, Has.Count.EqualTo(3), Does.Contain("x")) and give descriptive failure messages. NUnit 4 removed the old classic Assert.AreEqual style from the main namespace into a legacy package, nudging teams toward the constraint model.

How it compares: compared with xUnit.net, NUnit is more flexible and attribute-rich, with [SetUp], [TearDown], [OneTimeSetUp], categories, explicit tests and parameterised tests via [TestCase] and [TestCaseSource]. That flexibility makes it popular for integration and UI automation suites (including Selenium and Playwright for .NET), where shared setup and categorisation matter. MSTest is the third major option, maintained by Microsoft.

In the quality loop, NUnit is used from unit tests through integration and functional suites, and integrates with Visual Studio, Rider, the .NET CLI and CI systems through its test adapter.

The source code is at nunit/nunit on GitHub under the MIT licence, with about 2,600 stars; the most recent commit was on 11 November 2026.

NUnit’s runner model is also worth knowing. Tests are executed by the NUnit engine through adapters: the NUnit test adapter for Visual Studio and dotnet test, and the NUnit Console runner for command-line and CI scenarios outside the .NET SDK. Results can be written in NUnit’s XML format, which most CI servers and reporting tools understand. Extensions add reporting formats and integrations, and frameworks such as SpecFlow’s successor Reqnroll and many Selenium and Playwright starter kits support NUnit as a back end. That reach means NUnit skills transfer well between projects, whether the suite is a handful of unit tests or a large nightly regression pack.

Features

  1. Constraint model: Assert.That with composable constraints and clear failure messages.
  2. Parameterised tests: [TestCase], [TestCaseSource], [Values], [Range] and combinatorial or pairwise strategies.
  3. Setup and teardown: [SetUp], [TearDown], [OneTimeSetUp] and [OneTimeTearDown] at fixture and namespace level.
  4. Categories and explicit tests: Filter runs by category and keep slow tests opt-in with [Explicit].
  5. Parallel execution: [Parallelizable] controls parallelism at assembly, fixture or test level.
  6. Multiple asserts: Assert.Multiple reports all failures in a block instead of stopping at the first.
  7. Test context: TestContext gives access to test names, parameters, output and attachments.
  8. Extensibility: Custom attributes, constraints and engine extensions.

Pros

  1. Flexible: Works well for unit tests and larger integration or UI suites.
  2. Long history: Extensive documentation, examples and community knowledge.
  3. Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
  4. Actively maintained: The repository had commits as recent as 11 November 2026.

Cons

  1. Major-version migrations: Moving from NUnit 3 to 4 or 5 involves breaking changes.
  2. Shared setup can hide coupling: [SetUp] and fixture state make it easier to write interdependent tests.
  3. Choice overload: Many ways to do the same thing can lead to inconsistent test styles.
  4. Adapter needed: Running in IDEs and dotnet test requires the NUnit3TestAdapter package (check docs for NUnit 5 specifics).

Create and run an NUnit project:

dotnet new nunit -n Shop.Tests
dotnet test

Tests using constraints and test cases:

[TestFixture]
public class CartTests
{
    private Cart _cart;

    [SetUp]
    public void SetUp() => _cart = new Cart();

    [TestCase(1, 10, 10)]
    [TestCase(3, 10, 30)]
    public void Total_is_quantity_times_price(int qty, decimal price, decimal expected)
    {
        _cart.Add("sku-1", qty, price);
        Assert.That(_cart.Total, Is.EqualTo(expected));
    }

    [Test, Category("slow")]
    public void Checkout_reports_all_problems()
    {
        var result = _cart.Validate();
        Assert.Multiple(() =>
        {
            Assert.That(result.Errors, Is.Empty);
            Assert.That(result.Warnings, Has.Count.LessThanOrEqualTo(1));
        });
    }
}

Run only fast tests:

dotnet test --filter "TestCategory!=slow"

Practical tips:

  1. Read the NUnit 4 and 5 migration guides before upgrading large suites.
  2. Use categories to split smoke, slow and integration tests in CI.
  3. Keep fixtures small so [SetUp] does not hide dependencies between tests.

Resources:

Pricing

NUnit is free and open source under the MIT licence.

  1. .NET teams wanting a flexible, attribute-rich framework.
  2. Automation engineers building Selenium or Playwright suites in C#.
  3. Teams with existing NUnit suites, now with a clear upgrade path to NUnit 5.
  4. Not a fit if you want an opinionated framework that enforces per-test isolation; consider xUnit.net.

Conclusion

NUnit is one of the oldest and most capable .NET testing frameworks, with expressive constraints, rich parameterisation and flexible setup.

NUnit 5 modernises it for current .NET while keeping the breadth that makes it a good fit from unit tests to large automation suites.

Compare

CheckOps pages that put NUnit next to related tools. There is no paid placement on these lists.

Alternatives

Other tools on CheckOps that cover similar ground. Open a page, or compare one with NUnit side by side.