CheckOps home

Tools directory

X

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+.

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

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

  1. Facts and theories: [Fact] for single tests and [Theory] with [InlineData], [MemberData] or [ClassData] for data-driven tests.
  2. Isolation by design: A fresh test-class instance per test prevents state leaking between tests.
  3. Constructor setup: Use the constructor for setup and IDisposable or IAsyncLifetime for cleanup.
  4. Fixtures: Class fixtures and collection fixtures share expensive resources such as databases or web hosts.
  5. Parallelism: Test collections run in parallel by default, with configuration to tune or disable it.
  6. Microsoft Testing Platform: v3 supports the new testing platform as well as VSTest.
  7. Extensibility: Custom attributes, data sources and runners for advanced scenarios.
  8. Output: ITestOutputHelper captures per-test logs, shown alongside failures.

Pros

  1. Clean defaults: No hidden shared state, which encourages independent tests.
  2. Broad tool support: Works in all major IDEs, the .NET CLI and CI systems.
  3. Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
  4. Actively maintained: The repository had commits as recent as 10 November 2026.
  5. Community: About 4,600 GitHub stars.

Cons

  1. Opinionated: Teams used to NUnit’s [SetUp] attributes need to adjust.
  2. v2 to v3 migration: Moving to v3 changes project structure and some APIs.
  3. Basic assertions: Many teams add FluentAssertions or Shouldly for richer assertions.
  4. Parallelism surprises: Shared static state can cause flaky tests once parallel execution is on.

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:

  1. Add Coverlet (coverlet.collector) to collect coverage in CI with dotnet test --collect:"XPlat Code Coverage".
  2. Use collection fixtures for resources that must not be shared in parallel.
  3. 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.

  1. .NET teams starting new test projects who want isolation by default.
  2. ASP.NET Core developers writing integration tests with WebApplicationFactory.
  3. Open-source .NET libraries following common ecosystem practice.
  4. 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.

Alternatives

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