Skip to main content

Know sooner.

TUnit is a testing framework for modern .NET. It checks your tests as you type, finds them as you build, and runs them the way you describe.

As you type

Mistakes show up in the editor.

Analyzers read your tests while you write them. A forgotten await, a hook with the wrong signature or a data source that doesn't fit its test is flagged in the editor, before anything runs.

Awaiting assertions
[Test]
public async Task Greeting_contains_name()
{
var greeting = Greet("Ada");
Assert.That(greeting).Contains("Ada");
}
TUnitAssertions0002 Assert statements must be awaited - all TUnit assertions return Task

As you build

Your tests are found by the compiler.

A source generator writes the code that registers every test while your project builds. Nothing scans assemblies with reflection at startup, so the first test starts straight away, and test projects can publish with Native AOT.

Native AOT support

Found at startup

  1. Build
  2. Start
  3. Scan assemblies for tests
  4. Run

TUnit

  1. Build, and write down every test
  2. Start
  3. Run
The order of work, not drawn to scale.

As it runs

Say how your tests relate. TUnit schedules the rest.

Tests run in parallel unless you say otherwise. When some of them share a database, need an order or would swamp a service, one attribute says so. Switch them on and watch the same run rearrange.

Control parallel execution
1.19 sNothing held back
A simulated run of 60 tests on 8 workers. Each bar is one test, as long as it took. Rules cost a little time and buy tests that don't trip over each other.

Measured

Raced in real time.

Every bar grows for exactly as long as that framework took to run the same tests in the latest benchmark run.

1.1×faster than the next fastest, MSTest

Async tests with simulated I/O.

  1. TUnit 1.81.16469 ms
  2. xUnit v3 4.0.3647 ms1.4× TUnit
  3. NUnit 5.0.0575 ms1.2× TUnit
  4. MSTest 4.5.2522 ms1.1× TUnit
Mean run time, 10 November 2026. .NET SDK 11.0.100 on GitHub Actions.All benchmarks and methodology

As it grows

From one method to the whole system.

The same framework drives integration tests, with shared infrastructure that starts once and is cleaned up after the last test using it finishes. One test method can also become many cases, fed from attributes, methods, classes or a matrix of values.

Data-driven tests

Three commands to your first test.

  1. dotnet new install TUnit.Templates
  2. dotnet new TUnit -n MyTests
  3. dotnet run --project MyTests

 

Write your first test

Moving from xUnit, NUnit, or MSTest?

The migration guides map each attribute, assertion, and hook you use today to its TUnit equivalent.

Compare frameworks