CheckOps
xUnit.net
xUnit.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+.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
xUnit.net is a free, open-source, community-focused unit testing tool for C#, F# and Visual Basic. Its README states that xUnit.net v3 supports .NET 8.0 or later and .NET Framework 4.7.2 or later, and that it works with the .NET SDK command-line tools, Visual Studio, Visual Studio Code, JetBrains Rider, NCrunch, and any environment compatible with Microsoft Testing Platform or VSTest.
The project is part of the .NET Foundation, licensed under Apache 2.0, and governed by a project lead. It was written by Jim Newkirk, one of the original authors of NUnit, and Brad Wilson, with the goal of applying lessons learned from earlier .NET frameworks. The result is deliberately opinionated: no [SetUp] or [TearDown] attributes, a new test class instance for every test, and constructor and IDisposable for setup and cleanup.
Version 3 was a significant redesign. Test projects in v3 are built as executables, can run directly with dotnet run or through Microsoft Testing Platform, and gain features such as explicit tests, dynamically skippable tests, a built-in test context and better cancellation support. The latest release on GitHub at review time was v3 4.0.2, published on 9 October 2026.
How it compares: NUnit offers a broader attribute set and a more flexible assertion model, and MSTest is Microsoft’s own framework with deep Visual Studio integration. xUnit.net’s isolation-by-default design and extensibility made it the framework used by many .NET open-source projects, and the .NET project templates include an xUnit option. All three run in the same tooling, so mixing them across solutions is possible but rarely useful.
In the quality loop, xUnit.net covers unit and integration tests for .NET libraries, ASP.NET Core APIs (often with WebApplicationFactory) and worker services, and its results feed coverage tools such as Coverlet and CI reports.
The source code is at xunit/xunit on GitHub under the Apache-2.0 licence, with about 4,600 stars; the most recent commit was on 10 November 2026.
Assertions in xUnit.net come from the built-in Assert class, which covers equality, collections, exceptions (Assert.Throws and Assert.ThrowsAsync), ranges, strings and events. It is intentionally compact, and v3 added improvements such as better collection and equivalence assertions. Teams that want fluent syntax commonly add Shouldly or FluentAssertions (note that FluentAssertions 8 moved to a commercial licence from Xceed, so check terms). For mocking, Moq and NSubstitute are the usual partners, and Coverlet collects coverage. Because every test gets a fresh class instance, xUnit.net tests rarely suffer from leftover state, which is one of the most common causes of flaky tests in other frameworks.
For ASP.NET Core, the combination of xUnit.net and WebApplicationFactory from Microsoft’s testing package is the documented way to run an app in memory and send real HTTP requests to it, which makes fast integration tests straightforward.
Features
- Facts and theories:
[Fact]for single tests and[Theory]with[InlineData],[MemberData]or[ClassData]for data-driven tests. - Isolation by design: A fresh test-class instance per test prevents state leaking between tests.
- Constructor setup: Use the constructor for setup and
IDisposableorIAsyncLifetimefor cleanup. - Fixtures: Class fixtures and collection fixtures share expensive resources such as databases or web hosts.
- Parallelism: Test collections run in parallel by default, with configuration to tune or disable it.
- Microsoft Testing Platform: v3 supports the new testing platform as well as VSTest.
- Extensibility: Custom attributes, data sources and runners for advanced scenarios.
- Output:
ITestOutputHelpercaptures per-test logs, shown alongside failures.
Pros
- Clean defaults: No hidden shared state, which encourages independent tests.
- Broad tool support: Works in all major IDEs, the .NET CLI and CI systems.
- Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 10 November 2026.
- Community: About 4,600 GitHub stars.
Cons
- Opinionated: Teams used to NUnit’s
[SetUp]attributes need to adjust. - v2 to v3 migration: Moving to v3 changes project structure and some APIs.
- Basic assertions: Many teams add FluentAssertions or Shouldly for richer assertions.
- Parallelism surprises: Shared static state can cause flaky tests once parallel execution is on.
Usage and Links (Example)
Create a test project and run it:
dotnet new install xunit.v3.templates
dotnet new xunit3 -n Shop.Tests
dotnet test
A fact and a theory:
public class PricingTests
{
[Fact]
public void Zero_discount_keeps_price()
=> Assert.Equal(100m, Pricing.Apply(100m, 0));
[Theory]
[InlineData(100, 10, 90)]
[InlineData(50, 50, 25)]
public void Applies_percentage_discount(decimal price, int pct, decimal expected)
=> Assert.Equal(expected, Pricing.Apply(price, pct));
}
Share an expensive resource with a class fixture:
public class DbFixture : IAsyncLifetime { /* start database, seed data */ }
public class OrderRepoTests(DbFixture db) : IClassFixture<DbFixture> { /* tests */ }
Practical tips:
- Add Coverlet (
coverlet.collector) to collect coverage in CI withdotnet test --collect:"XPlat Code Coverage". - Use collection fixtures for resources that must not be shared in parallel.
- Check the xUnit.net docs for the current template names and v3 migration notes.
Resources:
Pricing
xUnit.net is free and open source under the Apache-2.0 licence.
Recommended for?
- .NET teams starting new test projects who want isolation by default.
- ASP.NET Core developers writing integration tests with
WebApplicationFactory. - Open-source .NET libraries following common ecosystem practice.
- Not a fit if your team relies heavily on NUnit-style setup attributes and does not want to change habits.
Conclusion
xUnit.net is a modern, opinionated .NET testing framework whose isolation-by-default design leads to cleaner, more independent tests.
With v3 and Microsoft Testing Platform support, it remains one of the strongest choices for .NET unit and integration testing.
Compare
CheckOps pages that put xUnit.net 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 xUnit.net side by side.
NNUnitNUnit 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.Compare with xUnit.net
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 xUnit.net
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 xUnit.net
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 xUnit.net
FFluent AssertionsFluent Assertions is a .NET assertions library with natural-language `Should()` syntax; versions 8 and later are free for open-source and non-commercial use but require a paid licence (via Xceed) for commercial use.Compare with xUnit.net
CCoverletCoverlet is an MIT-licensed cross-platform code coverage framework for .NET, with line, branch and method coverage, available as a VSTest collector, MSBuild integration or global tool.Compare with xUnit.net