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
Core Features
Everything you need for modern test development
Flexible Test Design
Multiple ways to write, inject data, and control tests. Support for data-driven testing, matrix tests, and custom data sources.
[Test]
[Arguments(1, 2, 3)]
[Arguments(4, 5, 9)]
public void TestAdd(int a, int b, int expected)
{
Assert.That(a + b).IsEqualTo(expected);
}
Intuitive Syntax
Clean attribute-based syntax that's easy to read and write. Fluent assertions make tests expressive and self-documenting.
[Test]
public async Task TestAsync()
{
var result = await GetDataAsync();
await Assert.That(result)
.IsNotNull()
.And.HasCount(5);
}
Performance Optimized
Source generated tests with Native AOT support. Built on Microsoft Testing Platform to reduce overhead and improve efficiency.
// AOT Compatible
[Test]
public void PerformantTest()
{
// Source generated
// No reflection overhead
Assert.That(true).IsTrue();
}
Why TUnit?
Built for modern .NET development
Performance Focused
Source generated code eliminates reflection overhead. Built on the modern Microsoft Testing Platform.
Compile-Time Validation
Source generators provide early error detection and full IntelliSense support.
AOT Compatible
Native AOT support enables faster startup times and reduced memory usage.
Extensible
Rich extension points and customization options to fit your testing needs.
Data Driven
Powerful data source attributes for parameterized and matrix testing.
Modern API
Fluent assertions, async-first design, and intuitive test organization.