TUnit.Core
1.18.0
Prefix Reserved
See the version list below for details.
dotnet add package TUnit.Core --version 1.18.0
NuGet\Install-Package TUnit.Core -Version 1.18.0
<PackageReference Include="TUnit.Core" Version="1.18.0" />
<PackageVersion Include="TUnit.Core" Version="1.18.0" />
<PackageReference Include="TUnit.Core" />
paket add TUnit.Core --version 1.18.0
#r "nuget: TUnit.Core, 1.18.0"
#:package TUnit.Core@1.18.0
#addin nuget:?package=TUnit.Core&version=1.18.0
#tool nuget:?package=TUnit.Core&version=1.18.0
TUnit
A modern .NET testing framework. Tests are source-generated at compile time, run in parallel by default, and support Native AOT — all built on Microsoft.Testing.Platform.
<div align="center">
</div>
Features
- Compile-time test discovery — tests are generated at build time rather than discovered via reflection at runtime, which means faster startup and better IDE integration
- Parallel by default — tests run concurrently; use
[DependsOn]to express ordering and[ParallelLimiter]to cap concurrency - Data-driven testing —
[Arguments],[Matrix],[ClassData], and customDataSourceGenerator<T>sources - Async assertions with detailed failure messages
- Built-in Roslyn analyzers — catch mistakes at compile time, such as missing
async, incorrect method signatures, and invalid attribute combinations - Extensible — write your own skip conditions, retry logic, and attributes
- Native AOT & trimming support
- Lifecycle hooks —
[Before]/[After]at method, class, assembly, or test session scope
Getting Started
Using the Project Template (Recommended)
dotnet new install TUnit.Templates
dotnet new TUnit -n "MyTestProject"
cd MyTestProject
dotnet run
Manual Installation
dotnet add package TUnit
Getting Started Guide · Migration Guides
Examples
Basic test with assertions
[Test]
public async Task Parsing_A_Valid_Date_Succeeds()
{
var date = DateTime.Parse("2025-01-01");
await Assert.That(date.Year).IsEqualTo(2025);
await Assert.That(date.Month).IsEqualTo(1);
}
Data-driven tests
[Test]
[Arguments("user1@test.com", "ValidPassword123")]
[Arguments("user2@test.com", "AnotherPassword456")]
[Arguments("admin@test.com", "AdminPass789")]
public async Task User_Login_Should_Succeed(string email, string password)
{
var result = await authService.LoginAsync(email, password);
await Assert.That(result.IsSuccess).IsTrue();
}
// Matrix — generates a test for every combination (9 total here)
[Test]
[MatrixDataSource]
public async Task Database_Operations_Work(
[Matrix("Create", "Update", "Delete")] string operation,
[Matrix("User", "Product", "Order")] string entity)
{
await Assert.That(await ExecuteOperation(operation, entity))
.IsTrue();
}
Hooks, dependencies, and retry
[Before(Class)]
public static async Task SetupDatabase(ClassHookContext context)
{
await DatabaseHelper.InitializeAsync();
}
[Test]
[MethodDataSource(nameof(GetTestUsers))]
public async Task Register_User(string username, string password) { ... }
[Test, DependsOn(nameof(Register_User))]
[Retry(3)]
public async Task Login_With_Registered_User(string username, string password)
{
// Guaranteed to run after Register_User passes
}
Custom attributes
Extend built-in base classes to create your own skip conditions, retry logic, and more:
public class WindowsOnlyAttribute : SkipAttribute
{
public WindowsOnlyAttribute() : base("Windows only") { }
public override Task<bool> ShouldSkip(TestContext testContext)
=> Task.FromResult(!OperatingSystem.IsWindows());
}
[Test, WindowsOnly]
public async Task Windows_Specific_Feature() { ... }
See the documentation for more examples, including custom retry logic and data sources.
IDE Support
| IDE | Notes |
|---|---|
| Visual Studio 2022 (17.13+) | Works out of the box |
| Visual Studio 2022 (earlier) | Enable "Use testing platform server mode" in Tools > Manage Preview Features |
| JetBrains Rider | Enable "Testing Platform support" in Settings > Build, Execution, Deployment > Unit Testing > Testing Platform |
| VS Code | Install C# Dev Kit and enable "Use Testing Platform Protocol" |
| CLI | Works with dotnet test, dotnet run, and direct execution |
Packages
| Package | Purpose |
|---|---|
TUnit |
Start here — the full framework (Core + Engine + Assertions) |
TUnit.Core |
Shared test library components without an execution engine |
TUnit.Engine |
Execution engine for test projects |
TUnit.Assertions |
Standalone assertions — works with other test frameworks too |
TUnit.Playwright |
Playwright integration with automatic browser lifecycle management |
Migrating from xUnit, NUnit, or MSTest?
The syntax will feel familiar. For example, xUnit's [Fact] becomes [Test], and [Theory] + [InlineData] becomes [Test] + [Arguments]. See the migration guides for full details: xUnit · NUnit · MSTest.
Community
- Documentation — guides, tutorials, and API reference
- GitHub Discussions — questions and ideas welcome
- Issues — bug reports and feature requests
- Changelog
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- System.Collections.Immutable (>= 9.0.0)
- System.Text.Json (>= 9.0.0)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (18)
Showing the top 5 NuGet packages that depend on TUnit.Core:
| Package | Downloads |
|---|---|
|
TUnit.Engine
A .NET Testing Framework |
|
|
Verify.TUnit
Enables verification of complex models and documents. |
|
|
Rocket.Surgery.Extensions.Testing.TUnit
Package Description |
|
|
NetEvolve.Extensions.TUnit
This library provides various compatibility features between `NUnit`, `XUnit`, `XUnit.V3`, `TUnit` and `MSTest`. |
|
|
Reqnroll.TUnit
Package to use Reqnroll with TUnit 1.3.25 and later. |
GitHub repositories (8)
Showing the top 8 popular GitHub repositories that depend on TUnit.Core:
| Repository | Stars |
|---|---|
|
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
|
|
|
VerifyTests/Verify
Verify is a snapshot testing tool that simplifies the assertion of complex data models and documents.
|
|
|
wiremock/WireMock.Net
WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on WireMock Java, but extended with more functionality.Full documentation can be found at https://wiremock.org/dotnet/.
|
|
|
reqnroll/Reqnroll
Open-source Cucumber-style BDD test automation framework for .NET.
|
|
|
Eventuous/eventuous
Event Sourcing library for .NET
|
|
|
thomhurst/ModularPipelines
Write your pipelines in C# !
|
|
|
SwissLife-OSS/snapshooter
Snapshooter is a snapshot testing tool for .NET Core and .NET Framework
|
|
|
DamianMorozov/OpenTgResearcher
OpenTgResearcher - tool for analyzing Telegram chats and downloading their content
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.18.9 | 0 | 3/3/2026 |
| 1.18.0 | 1,745 | 3/2/2026 |
| 1.17.54 | 2,829 | 2/27/2026 |
| 1.17.36 | 4,473 | 2/26/2026 |
| 1.17.29 | 2,938 | 2/26/2026 |
| 1.17.25 | 1,885 | 2/25/2026 |
| 1.17.20 | 571 | 2/25/2026 |
| 1.17.11 | 5,571 | 2/24/2026 |
| 1.17.7 | 4,603 | 2/22/2026 |
| 1.17.4 | 983 | 2/22/2026 |
| 1.17.0 | 869 | 2/22/2026 |
| 1.16.4 | 18,603 | 2/18/2026 |
| 1.16.0 | 3,613 | 2/18/2026 |
| 1.15.11 | 4,313 | 2/18/2026 |
| 1.15.7 | 1,711 | 2/17/2026 |
| 1.15.0 | 10,577 | 2/15/2026 |
| 1.14.0 | 2,987 | 2/14/2026 |
| 1.13.70 | 752 | 2/14/2026 |
| 1.13.69 | 398 | 2/14/2026 |
| 1.13.60 | 3,246 | 2/13/2026 |