VOOZH about

URL: https://www.nuget.org/packages/TUnit/

⇱ NuGet Gallery | TUnit 1.56.0


ο»Ώ
dotnet add package TUnit --version 1.56.0
 
 
NuGet\Install-Package TUnit -Version 1.56.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TUnit" Version="1.56.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TUnit" Version="1.56.0" />
 
Directory.Packages.props
<PackageReference Include="TUnit" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TUnit --version 1.56.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TUnit, 1.56.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TUnit@1.56.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TUnit&version=1.56.0
 
Install as a Cake Addin
#tool nuget:?package=TUnit&version=1.56.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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">

πŸ‘ Codacy Badge
πŸ‘ GitHub Repo stars
πŸ‘ GitHub Issues or Pull Requests
πŸ‘ GitHub Sponsors
πŸ‘ nuget
πŸ‘ NuGet Downloads
πŸ‘ GitHub Workflow Status (with event)
πŸ‘ GitHub last commit (branch)
πŸ‘ License

</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 custom DataSourceGenerator<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.Assertions.Should Optional FluentAssertions-style value.Should().BeEqualTo(...) syntax over TUnit.Assertions (beta)
TUnit.Mocks Source-generated, AOT-compatible mocking framework β€” works with any test runner
TUnit.Mocks.Http HttpClient mocking helpers built on TUnit.Mocks
TUnit.Mocks.Logging ILogger capture/verification helpers built on TUnit.Mocks
TUnit.AspNetCore ASP.NET Core integration β€” WebApplicationFactory-based test fixtures
TUnit.Aspire Aspire integration β€” distributed app host fixtures with OpenTelemetry capture
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

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on TUnit:

Package Downloads
TUnit.Playwright

A .NET Testing Framework

Saucery.TUnit

Sorcery for SauceLabs - Unlocking SauceLabs capability

TUnit.AspNetCore

A .NET Testing Framework

TUnit.Aspire

A .NET Testing Framework

Rewrite.Test

Test harness for the automated code refactoring framework OpenRewrite.

GitHub repositories (70)

Showing the top 20 popular GitHub repositories that depend on TUnit:

Repository Stars
MaterialDesignInXAML/MaterialDesignInXamlToolkit
Google's Material Design in XAML & WPF, for C# & VB.Net.
reactiveui/refit
The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
reactiveui/ReactiveUI
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
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.
HMBSbige/NatTypeTester
ζ΅‹θ―•ε½“ε‰η½‘η»œηš„ NAT η±»εž‹οΌˆSTUNοΌ‰
Cysharp/MagicOnion
Unified Realtime/API framework for .NET platform and Unity.
fluentassertions/fluentassertions
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, as well as .NET Core 2.1, .NET Core 3.0, .NET 6, .NET Standard 2.0 and 2.1. Supports the unit test frameworks MSTest2, NUnit3, XUnit2, MSpec, and NSpec3.
VerifyTests/Verify
Verify is a snapshot testing tool that simplifies the assertion of complex data models and documents.
dotnet/skills
Repository for skills to assist AI coding agents with .NET and C#
shouldly/shouldly
Should testing for .NETβ€”the way assertions should be!
reactiveui/Akavache
An asynchronous, persistent key-value store created for writing desktop and mobile applications, based on SQLite3. Akavache is great for both storing important data as well as cached local data that expires.
OPCFoundation/UA-.NETStandard
OPC Unified Architecture .NET Standard
belav/csharpier
CSharpier is an opinionated code formatter for c#.
Cysharp/ConsoleAppFramework
Zero Dependency, Zero Overhead, Zero Reflection, Zero Allocation, AOT Safe CLI Framework powered by C# Source Generator.
Nexus-Mods/NexusMods.App
Home of the development of the Nexus Mods App
stryker-mutator/stryker-net
Mutation testing for .NET core and .NET framework!
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 and different functionality. Full documentation can be found at https://wiremock.org/dotnet/.
lookup-foundation/RevitLookup
Interactive Revit RFA and RVT project database exploration tool to view and navigate BIM element parameters, properties and relationships.
TNG/ArchUnitNET
A C# architecture test library to specify and assert architecture rules in C# for automated testing.
ncalc/ncalc
NCalc is a fast and lightweight expression evaluator library for .NET, designed for flexibility and high performance. It supports a wide range of mathematical and logical operations.
Version Downloads Last Updated
1.56.0 18,331 6/15/2026
1.55.2 8,677 6/14/2026
1.55.0 2,100 6/14/2026
1.54.0 9,089 6/12/2026
1.53.0 43,365 6/8/2026
1.51.0 10,502 6/7/2026
1.50.0 22,552 6/5/2026
1.49.0 14,174 6/3/2026
1.48.6 59,706 6/1/2026
1.48.0 5,190 5/31/2026
1.47.0 18,993 5/29/2026
1.46.0 4,902 5/28/2026
1.45.29 43,347 5/21/2026
1.45.22 11,395 5/20/2026
1.45.8 24,296 5/18/2026
1.45.0 14,803 5/18/2026
1.44.39 23,482 5/14/2026
1.44.0 55,174 5/10/2026
1.43.41 9,816 5/9/2026
1.43.38 2,298 5/8/2026
Loading failed