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.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
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
- Constraint model:
Assert.Thatwith composable constraints and clear failure messages. - Parameterised tests:
[TestCase],[TestCaseSource],[Values],[Range]and combinatorial or pairwise strategies. - Setup and teardown:
[SetUp],[TearDown],[OneTimeSetUp]and[OneTimeTearDown]at fixture and namespace level. - Categories and explicit tests: Filter runs by category and keep slow tests opt-in with
[Explicit]. - Parallel execution:
[Parallelizable]controls parallelism at assembly, fixture or test level. - Multiple asserts:
Assert.Multiplereports all failures in a block instead of stopping at the first. - Test context:
TestContextgives access to test names, parameters, output and attachments. - Extensibility: Custom attributes, constraints and engine extensions.
Pros
- Flexible: Works well for unit tests and larger integration or UI suites.
- Long history: Extensive documentation, examples and community knowledge.
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 11 November 2026.
Cons
- Major-version migrations: Moving from NUnit 3 to 4 or 5 involves breaking changes.
- Shared setup can hide coupling:
[SetUp]and fixture state make it easier to write interdependent tests. - Choice overload: Many ways to do the same thing can lead to inconsistent test styles.
- Adapter needed: Running in IDEs and
dotnet testrequires the NUnit3TestAdapter package (check docs for NUnit 5 specifics).
Usage and Links (Example)
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:
- Read the NUnit 4 and 5 migration guides before upgrading large suites.
- Use categories to split smoke, slow and integration tests in CI.
- Keep fixtures small so
[SetUp]does not hide dependencies between tests.
Resources:
Pricing
NUnit is free and open source under the MIT licence.
Recommended for?
- .NET teams wanting a flexible, attribute-rich framework.
- Automation engineers building Selenium or Playwright suites in C#.
- Teams with existing NUnit suites, now with a clear upgrade path to NUnit 5.
- 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.
Roundups
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with NUnit side by side.
XxUnit.netxUnit.net is a free, Apache-2.0, community-focused unit testing tool for C#, F# and Visual Basic, part of the .NET Foundation; v3 supports .NET 8+ and .NET Framework 4.7.2+.Compare with NUnit
MMSTestMSTest is Microsoft's MIT-licensed test framework for .NET, developed in the microsoft/testfx repository alongside Microsoft.Testing.Platform, a lightweight alternative to VSTest, with the MSTest.Sdk project SDK.Compare with NUnit
MMoqMoq is a popular MIT-licensed mocking library for .NET that uses lambda expressions to set up and verify mocks; stable v4.x is maintained on the v4 branch while the main branch hosts the upcoming v5.Compare with NUnit
NNSubstituteNSubstitute is a BSD-3-Clause mocking library for .NET with a concise, readable syntax for creating substitutes, configuring returns and checking received calls.Compare with NUnit
SShouldlyShouldly is a BSD-3-Clause .NET assertion library focused on readable code and great failure messages that include the source expression being tested.Compare with NUnit
TTestNGTestNG is an Apache-2.0 testing framework for Java, inspired by JUnit and NUnit, with annotations, groups, dependencies, data providers, parallel execution and XML suite configuration; it requires Java 11+.Compare with NUnit