CheckOps home

Tools directory

T

CheckOps

TUnit

TUnit is a modern MIT-licensed .NET testing framework built on Microsoft.Testing.Platform that discovers tests at compile time with source generators, runs them in parallel by default and supports Native AOT.

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

TUnit is a testing framework for modern .NET. In its own words, it checks your tests as you type, finds them as you build and runs them the way you describe. It is built on Microsoft.Testing.Platform, the newer test platform from Microsoft, rather than the older VSTest stack.

The biggest architectural difference from xUnit, NUnit and MSTest is compile-time test discovery. A source generator writes the code that registers every test while your project builds, so nothing scans assemblies with reflection at runtime. That gives faster startup, better IDE integration and full support for Native AOT and trimming. You pay a little at build time, and every run afterwards starts faster, dramatically so under Native AOT. TUnit publishes a weekly-regenerated speed comparison against xUnit v3, NUnit and MSTest with full methodology on its benchmarks page.

Compile-time safety comes from a suite of Roslyn analyzers shipped in the box. A forgotten await, a hook with the wrong signature or a data source that does not fit its test is flagged in the editor before anything runs; for example TUnitAssertions0002 reports that assert statements must be awaited. Mistakes fail your build, not your CI run.

Tests run concurrently by default, with precise control when you need it: [DependsOn] orders tests, [NotInParallel] serialises them and [ParallelLimiter] throttles concurrency. Data-driven testing supports arguments, matrix tests that generate a test for every combination, [MethodDataSource] for rows from a method and custom DataSourceGenerator attributes.

Assertions are async and chainable, such as await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK), and failure messages are focused: TUnit shows the expression you wrote and, when comparing objects, pinpoints the differing member instead of dumping two object graphs. Defining a custom assertion takes one attribute on a plain method, and TUnit generates the fluent extension.

For fixtures, [ClassDataSource] injects dependencies into test classes, IAsyncInitializer and IAsyncDisposable handle async setup and teardown, and sharing scopes include None, PerClass, PerAssembly, PerTestSession and Keyed, which is ideal for expensive resources such as a Postgres container. Lifecycle hooks exist at every scope, and a source-generated mocking library is included, with first-class integrations for ASP.NET Core, Aspire and Playwright.

Migrating from xUnit or NUnit is mostly mechanical, but the async assertion style and Microsoft.Testing.Platform runner are real changes, so try it on a new test project first and compare run times in your CI.

The source code is at thomhurst/TUnit on GitHub under the MIT licence, with about 4,000 stars; the most recent commit was on 11 November 2026.

Teams already using xUnit can adopt TUnit gradually by creating a new test project for new features, which avoids a big-bang migration while letting developers learn the async assertion style.

Run the test suite with the analyzers enabled from day one, and treat analyzer warnings as errors in CI. Much of TUnit’s value comes from catching mistakes at build time, and that only works if the warnings cannot be ignored.

For libraries that target several .NET versions, check compatibility early, since source generators and Microsoft.Testing.Platform have their own requirements that may differ from older test stacks.

Features

  1. Compile-time discovery: Source generators, no runtime reflection.
  2. Native AOT support: Run tests trimmed and AOT-compiled.
  3. Roslyn analyzers: Mistakes fail the build.
  4. Parallel by default: With DependsOn, NotInParallel and ParallelLimiter.
  5. Data-driven tests: Arguments, matrix and method data sources.
  6. Async fluent assertions: Focused failure messages.
  7. Custom assertions: One attribute generates an extension.
  8. Dependency injection: ClassDataSource with sharing scopes.
  9. Built-in mocking: Source-generated mocks.
  10. Integrations: ASP.NET Core, Aspire and Playwright.

Pros

  1. Fast startup: Especially under AOT.
  2. Modern platform: Built on Microsoft.Testing.Platform.
  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.
  5. Community: About 4,000 GitHub stars.

Cons

  1. Migration cost: Different attributes and async assertions.
  2. Younger ecosystem: Fewer third-party extensions than xUnit or NUnit.
  3. Tooling differences: Some older CI tooling expects VSTest.
dotnet new install TUnit.Templates
dotnet new TUnit -n "MyTestProject"
dotnet run --project MyTestProject
[Test]
[Arguments("gold", 100.0, 90.0)]
public async Task Discount_Is_Applied(string tier, double subtotal, double expected)
{
    var total = await checkout.ApplyDiscountAsync(tier, subtotal);
    await Assert.That(total).IsEqualTo(expected);
}

Resources:

Pricing

TUnit is free and open source under the MIT licence.

  1. .NET teams starting new test projects.
  2. Teams using Native AOT.
  3. Large suites that benefit from parallel-by-default execution.

Conclusion

TUnit is the most forward-looking .NET test framework today, with compile-time safety and excellent performance.

Pilot it on a new project before migrating an established suite.

On CheckOps, TUnit is filed under the Unit testing and Integration testing stages. Related tools listed here include xUnit.net, NUnit, Fluent Assertions, Shouldly, Moq and BenchmarkDotNet. When comparing them, weigh the licence, the languages and platforms each supports, whether it is self-hosted or managed, and how cleanly it slots into your existing CI pipeline. Details on this page were checked against the official website, documentation and repository on 11 November 2026.

Alternatives

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