TUnit is a modern .NET testing framework that discovers tests at compile time via source generators, runs tests in parallel by default, and supports Native AOT compilation.
TUnit solves the performance and flexibility limitations of traditional .NET testing frameworks by shifting test discovery from runtime reflection to compile-time source generation. This approach eliminates the startup overhead of scanning assemblies and enables full trimming and Native AOT support. Tests run in parallel by default, with fine-grained control through attributes like DependsOn, NotInParallel, and ParallelLimiter to enforce ordering and concurrency limits where needed. The framework includes Roslyn analyzers that catch common mistakes—invalid hook signatures, broken data sources, misused assertions—at build time rather than in CI. It provides rich async assertions, shared fixtures with dependency injection, lifecycle hooks at multiple scopes, and a source-generated mocking library, with first-class support for ASP.NET Core, Aspire, and Playwright.
Teams should adopt TUnit if they prioritize test execution speed, especially in large test suites or when using Native AOT, and value compile-time safety over runtime flexibility. It suits projects that benefit from parallel test execution and those targeting high-performance scenarios. The framework is particularly valuable for teams already invested in the .NET ecosystem who want to move beyond reflection-based discovery and gain the startup performance benefits of source generation.
The project maintains active development with regular commits to the main branch and a responsive approach to issues and pull requests. The maintainer actively engages with the community through sponsorship options and keeps the framework aligned with Microsoft.Testing.Platform standards.