Quick Start
Get up and running in seconds
Install
dotnet add package TUnit
Write
[Test]
public async Task TestAddition()
{
await Assert.That(1 + 1).IsEqualTo(2);
}
Run
dotnet test
Choose Your Journey
Where would you like to start?
New to TUnit
Start from scratch and learn the fundamentals
Migrating to TUnit
Switch to TUnit from xUnit, NUnit, or MSTest
Essential Features
Master the core TUnit capabilities
Advanced & Optimization
Optimize performance and extend TUnit
Core Features
Everything you need for modern test development
Flexible Test Design
Data-driven arguments, matrix tests, and custom data sources — plus injectable, shared fixtures with dependency injection and reference-counted disposal.
[Test]
[Arguments(1, 2, 3)]
[Arguments(4, 5, 9)]
public async Task TestAdd(int a, int b, int expected)
{
await Assert.That(a + b).IsEqualTo(expected);
}
Intuitive Syntax
Clean, attribute-based tests with fluent async assertions that read like sentences — and pinpoint the exact difference when they fail, instead of dumping object graphs at you.
[Test]
public async Task TestAsync()
{
var result = await GetDataAsync();
await Assert.That(result)
.IsNotNull()
.And.Count().IsEqualTo(5);
}
Performance Optimized
Source-generated tests with Native AOT support, built on the Microsoft Testing Platform. Work shifts from run time to build time, so every run after starts faster.
// AOT Compatible
[Test]
public async Task PerformantTest()
{
// Source generated
// No reflection overhead
await Assert.That(true).IsTrue();
}
Why TUnit?
Built for modern .NET development
Compile-Time Discovery
Tests are wired up by a source generator at build time, not found via reflection at runtime — faster startup, better IDE integration, and full Native AOT / trimming support.
Compile-Time Safety
A suite of Roslyn analyzers ships in the box, so invalid hook signatures, broken data sources, and misused assertions fail your build — not your CI run.
Parallel by Default
Tests run concurrently out of the box; [DependsOn], [NotInParallel], and [ParallelLimiter<T>] give you precise ordering and throttling when you need it.
Batteries Included
Rich async assertions, shared fixtures with dependency injection, and lifecycle hooks at every scope — plus a source-generated mocking library.
First-Class Integrations
Purpose-built support for ASP.NET Core, Aspire, and Playwright, so integration and end-to-end tests feel native to the framework.
AOT & Trimming Ready
Native AOT support enables dramatically faster startup and reduced memory usage, with no runtime reflection to trim away.