TUnit.Assertions.FSharp
0.25.21
Prefix Reserved
dotnet add package TUnit.Assertions.FSharp --version 0.25.21
NuGet\Install-Package TUnit.Assertions.FSharp -Version 0.25.21
<PackageReference Include="TUnit.Assertions.FSharp" Version="0.25.21" />
<PackageVersion Include="TUnit.Assertions.FSharp" Version="0.25.21" />
<PackageReference Include="TUnit.Assertions.FSharp" />
paket add TUnit.Assertions.FSharp --version 0.25.21
#r "nuget: TUnit.Assertions.FSharp, 0.25.21"
#addin nuget:?package=TUnit.Assertions.FSharp&version=0.25.21
#tool nuget:?package=TUnit.Assertions.FSharp&version=0.25.21
๐ The Modern Testing Framework for .NET
TUnit is a next-generation testing framework for C# that outpaces traditional frameworks with source-generated tests, parallel execution by default, and Native AOT support. Built on the modern Microsoft.Testing.Platform, TUnit delivers faster test runs, better developer experience, and unmatched flexibility.
<div align="center">
</div>
โก Why Choose TUnit?
Feature | Traditional Frameworks | TUnit |
---|---|---|
Test Discovery | โ Runtime reflection | โ Compile-time generation |
Execution Speed | โ Sequential by default | โ Parallel by default |
Modern .NET | โ ๏ธ Limited AOT support | โ Full Native AOT & trimming |
Test Dependencies | โ Not supported | โ
[DependsOn] chains |
Resource Management | โ Manual lifecycle | โ Intelligent cleanup |
โก Parallel by Default - Tests run concurrently with intelligent dependency management
๐ฏ Compile-Time Discovery - Know your test structure before runtime
๐ง Modern .NET Ready - Native AOT, trimming, and latest .NET features
๐ญ Extensible - Customize data sources, attributes, and test behavior
<div align="center">
๐ Complete Documentation & Learning Center
๐ New to TUnit? Start with our Getting Started Guide
๐ Migrating? See our Migration Guides
๐ฏ Advanced Features? Explore Data-Driven Testing, Test Dependencies, and Parallelism Control
</div>
๐ Quick Start
Using the Project Template (Recommended)
dotnet new install TUnit.Templates
dotnet new TUnit -n "MyTestProject"
Manual Installation
dotnet add package TUnit --prerelease
๐ ๐ Complete Documentation & Guides - Everything you need to master TUnit
โจ Key Features
<table> <tr> <td width="50%">
๐ Performance & Modern Platform
- ๐ฅ Source-generated tests (no reflection)
- โก Parallel execution by default
- ๐ Native AOT & trimming support
- ๐ Optimized for performance
</td> <td width="50%">
๐ฏ Advanced Test Control
- ๐ Test dependencies with
[DependsOn]
- ๐๏ธ Parallel limits & custom scheduling
- ๐ก๏ธ Built-in analyzers & compile-time checks
- ๐ญ Custom attributes & extensible conditions
</td> </tr> <tr> <td>
๐ Rich Data & Assertions
- ๐ Multiple data sources (
[Arguments]
,[Matrix]
,[ClassData]
) - โ Fluent async assertions
- ๐ Smart retry logic & conditional execution
- ๐ Rich test metadata & context
</td> <td>
๐ง Developer Experience
- ๐ Full dependency injection support
- ๐ช Comprehensive lifecycle hooks
- ๐ฏ IDE integration (VS, Rider, VS Code)
- ๐ Extensive documentation & examples
</td> </tr> </table>
๐ Simple Test Example
[Test]
public async Task User_Creation_Should_Set_Timestamp()
{
// Arrange
var userService = new UserService();
// Act
var user = await userService.CreateUserAsync("john.doe@example.com");
// Assert - TUnit's fluent assertions
await Assert.That(user.CreatedAt)
.IsEqualTo(DateTime.Now)
.Within(TimeSpan.FromMinutes(1));
await Assert.That(user.Email)
.IsEqualTo("john.doe@example.com");
}
๐ฏ Data-Driven Testing
[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 testing - tests all combinations
[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();
}
๐ Advanced Test Orchestration
[Before(Class)]
public static async Task SetupDatabase(ClassHookContext context)
{
await DatabaseHelper.InitializeAsync();
}
[Test, DisplayName("Register a new account")]
[MethodDataSource(nameof(GetTestUsers))]
public async Task Register_User(string username, string password)
{
// Test implementation
}
[Test, DependsOn(nameof(Register_User))]
[Retry(3)] // Retry on failure
public async Task Login_With_Registered_User(string username, string password)
{
// This test runs after Register_User completes
}
[Test]
[ParallelLimit<LoadTestParallelLimit>] // Custom parallel control
[Repeat(100)] // Run 100 times
public async Task Load_Test_Homepage()
{
// Performance testing
}
// Custom attributes
[Test, WindowsOnly, RetryOnHttpError(5)]
public async Task Windows_Specific_Feature()
{
// Platform-specific test with custom retry logic
}
public class LoadTestParallelLimit : IParallelLimit
{
public int Limit => 10; // Limit to 10 concurrent executions
}
๐ง Smart Test Control
// Custom conditional execution
public class WindowsOnlyAttribute : SkipAttribute
{
public WindowsOnlyAttribute() : base("Windows only test") { }
public override Task<bool> ShouldSkip(TestContext testContext)
=> Task.FromResult(!OperatingSystem.IsWindows());
}
// Custom retry logic
public class RetryOnHttpErrorAttribute : RetryAttribute
{
public RetryOnHttpErrorAttribute(int times) : base(times) { }
public override Task<bool> ShouldRetry(TestInformation testInformation,
Exception exception, int currentRetryCount)
=> Task.FromResult(exception is HttpRequestException { StatusCode: HttpStatusCode.ServiceUnavailable });
}
๐ฏ Perfect For Every Testing Scenario
<table> <tr> <td width="33%">
๐งช Unit Testing
[Test]
[Arguments(1, 2, 3)]
[Arguments(5, 10, 15)]
public async Task Calculate_Sum(int a, int b, int expected)
{
await Assert.That(Calculator.Add(a, b))
.IsEqualTo(expected);
}
Fast, isolated, and reliable
</td> <td width="33%">
๐ Integration Testing
[Test, DependsOn(nameof(CreateUser))]
public async Task Login_After_Registration()
{
// Runs after CreateUser completes
var result = await authService.Login(user);
await Assert.That(result.IsSuccess).IsTrue();
}
Stateful workflows made simple
</td> <td width="33%">
โก Load Testing
[Test]
[ParallelLimit<LoadTestLimit>]
[Repeat(1000)]
public async Task API_Handles_Concurrent_Requests()
{
await Assert.That(await httpClient.GetAsync("/api/health"))
.HasStatusCode(HttpStatusCode.OK);
}
Built-in performance testing
</td> </tr> </table>
๐ What Makes TUnit Different?
Compile-Time Intelligence
Tests are discovered at build time, not runtime - enabling faster discovery, better IDE integration, and precise resource lifecycle management.
Parallel-First Architecture
Built for concurrency from day one with [DependsOn]
for test chains, [ParallelLimit]
for resource control, and intelligent scheduling.
Extensible by Design
The DataSourceGenerator<T>
pattern and custom attribute system let you extend TUnit's capabilities without modifying core framework code.
๐ Community & Ecosystem
<div align="center">
๐ Join thousands of developers modernizing their testing
</div>
๐ค Active Community
- ๐ Official Documentation - Comprehensive guides, tutorials, and API reference
- ๐ฌ GitHub Discussions - Get help and share ideas
- ๐ Issue Tracking - Report bugs and request features
- ๐ข Release Notes - Stay updated with latest improvements
๐ ๏ธ IDE Support
TUnit works seamlessly across all major .NET development environments:
Visual Studio (2022 17.13+)
โ Fully supported - No additional configuration needed for latest versions
โ๏ธ Earlier versions: Enable "Use testing platform server mode" in Tools > Manage Preview Features
JetBrains Rider
โ Fully supported
โ๏ธ Setup: Enable "Testing Platform support" in Settings > Build, Execution, Deployment > Unit Testing > VSTest
Visual Studio Code
โ Fully supported
โ๏ธ Setup: Install C# Dev Kit and enable "Use Testing Platform Protocol"
Command Line
โ
Full CLI support - Works with dotnet test
, dotnet run
, and direct executable execution
๐ฆ Package Options
Package | Use Case |
---|---|
TUnit |
โญ Start here - Complete testing framework (includes Core + Engine + Assertions) |
TUnit.Core |
๐ Test libraries and shared components (no execution engine) |
TUnit.Engine |
๐ Test execution engine and adapter (for test projects) |
TUnit.Assertions |
โ Standalone assertions (works with any test framework) |
TUnit.Playwright |
๐ญ Playwright integration with automatic lifecycle management |
๐ฏ Migration from Other Frameworks
Coming from NUnit or xUnit? TUnit maintains familiar syntax while adding modern capabilities:
// Enhanced with TUnit's advanced features
[Test]
[Arguments("value1")]
[Arguments("value2")]
[Retry(3)]
[ParallelLimit<CustomLimit>]
public async Task Modern_TUnit_Test(string value) { }
๐ Need help migrating? Check our detailed Migration Guides with step-by-step instructions for xUnit, NUnit, and MSTest.
๐ก Current Status
The API is mostly stable, but may have some changes based on feedback or issues before v1.0 release.
<div align="center">
๐ Ready to Experience the Future of .NET Testing?
โก Start in 30 Seconds
# Create a new test project with examples
dotnet new install TUnit.Templates && dotnet new TUnit -n "MyAwesomeTests"
# Or add to existing project
dotnet add package TUnit --prerelease
๐ฏ Why Wait? Join the Movement
<table> <tr> <td align="center" width="25%">
๐ Performance
Optimized execution Parallel by default Zero reflection overhead
</td> <td align="center" width="25%">
๐ฎ Future-Ready
Native AOT support Latest .NET features Source generation
</td> <td align="center" width="25%">
๐ ๏ธ Developer Experience
Compile-time checks Rich IDE integration Intelligent debugging
</td> <td align="center" width="25%">
๐ญ Flexibility
Test dependencies Custom attributes Extensible architecture
</td> </tr> </table>
๐ Learn More: tunit.dev | ๐ฌ Get Help: GitHub Discussions | โญ Show Support: Star on GitHub
TUnit is actively developed and production-ready. Join our growing community of developers who've made the switch!
</div>
Performance Benchmark
Scenario: Building the test project
macos-latest
BenchmarkDotNet v0.15.1, macOS Sonoma 14.7.6 (23H626) [Darwin 23.6.0]
Apple M1 (Virtual), 1 CPU, 3 logical and 3 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), Arm64 RyuJIT AdvSIMD
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), Arm64 RyuJIT AdvSIMD
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev | Median |
---|---|---|---|---|
Build_TUnit | 1,095.9 ms | 55.61 ms | 160.46 ms | 1,033.7 ms |
Build_NUnit | 839.2 ms | 16.76 ms | 25.09 ms | 838.6 ms |
Build_xUnit | 809.8 ms | 15.37 ms | 22.53 ms | 808.3 ms |
Build_MSTest | 810.8 ms | 16.01 ms | 38.04 ms | 792.5 ms |
ubuntu-latest
BenchmarkDotNet v0.15.1, Linux Ubuntu 24.04.2 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev |
---|---|---|---|
Build_TUnit | 1.882 s | 0.0363 s | 0.0544 s |
Build_NUnit | 1.468 s | 0.0227 s | 0.0212 s |
Build_xUnit | 1.469 s | 0.0290 s | 0.0415 s |
Build_MSTest | 1.476 s | 0.0292 s | 0.0312 s |
windows-latest
BenchmarkDotNet v0.15.1, Windows 10 (10.0.20348.3561) (Hyper-V)
AMD EPYC 7763 2.44GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev |
---|---|---|---|
Build_TUnit | 1.934 s | 0.0378 s | 0.0652 s |
Build_NUnit | 1.512 s | 0.0116 s | 0.0097 s |
Build_xUnit | 1.492 s | 0.0173 s | 0.0162 s |
Build_MSTest | 1.539 s | 0.0167 s | 0.0157 s |
Scenario: A single test that completes instantly (including spawning a new process and initialising the test framework)
macos-latest
BenchmarkDotNet v0.15.1, macOS Sonoma 14.7.6 (23H626) [Darwin 23.6.0]
Apple M1 (Virtual), 1 CPU, 3 logical and 3 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), Arm64 RyuJIT AdvSIMD
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), Arm64 RyuJIT AdvSIMD
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev | Median |
---|---|---|---|---|
TUnit_AOT | 70.87 ms | 1.358 ms | 1.718 ms | 70.50 ms |
TUnit | 483.73 ms | 9.135 ms | 16.704 ms | 478.81 ms |
NUnit | 721.73 ms | 14.373 ms | 37.612 ms | 704.97 ms |
xUnit | 728.46 ms | 10.863 ms | 10.668 ms | 729.08 ms |
MSTest | 619.42 ms | 8.239 ms | 7.304 ms | 617.74 ms |
ubuntu-latest
BenchmarkDotNet v0.15.1, Linux Ubuntu 24.04.2 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev |
---|---|---|---|
TUnit_AOT | 27.94 ms | 0.584 ms | 1.713 ms |
TUnit | 837.56 ms | 16.433 ms | 20.783 ms |
NUnit | 1,314.99 ms | 17.786 ms | 16.637 ms |
xUnit | 1,381.22 ms | 14.792 ms | 13.113 ms |
MSTest | 1,176.63 ms | 23.003 ms | 21.517 ms |
windows-latest
BenchmarkDotNet v0.15.1, Windows 10 (10.0.20348.3561) (Hyper-V)
AMD EPYC 7763 2.44GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev |
---|---|---|---|
TUnit_AOT | 58.50 ms | 1.780 ms | 5.250 ms |
TUnit | 865.35 ms | 17.209 ms | 25.225 ms |
NUnit | 1,288.20 ms | 10.914 ms | 10.209 ms |
xUnit | 1,328.49 ms | 14.863 ms | 13.903 ms |
MSTest | 1,141.89 ms | 9.761 ms | 8.653 ms |
Scenario: A test that takes 50ms to execute, repeated 100 times (including spawning a new process and initialising the test framework)
macos-latest
BenchmarkDotNet v0.15.1, macOS Sonoma 14.7.6 (23H626) [Darwin 23.6.0]
Apple M1 (Virtual), 1 CPU, 3 logical and 3 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), Arm64 RyuJIT AdvSIMD
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), Arm64 RyuJIT AdvSIMD
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev |
---|---|---|---|
TUnit_AOT | 243.3 ms | 14.80 ms | 43.65 ms |
TUnit | 683.3 ms | 23.02 ms | 67.88 ms |
NUnit | 14,069.9 ms | 279.44 ms | 545.03 ms |
xUnit | 14,244.1 ms | 284.06 ms | 416.37 ms |
MSTest | 14,242.6 ms | 282.94 ms | 502.93 ms |
ubuntu-latest
BenchmarkDotNet v0.15.1, Linux Ubuntu 24.04.2 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev |
---|---|---|---|
TUnit_AOT | 74.83 ms | 1.459 ms | 1.622 ms |
TUnit | 891.96 ms | 17.616 ms | 24.695 ms |
NUnit | 6,261.05 ms | 10.030 ms | 8.892 ms |
xUnit | 6,408.39 ms | 7.017 ms | 6.564 ms |
MSTest | 6,229.08 ms | 13.224 ms | 11.723 ms |
windows-latest
BenchmarkDotNet v0.15.1, Windows 10 (10.0.20348.3695) (Hyper-V)
AMD EPYC 7763 2.44GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 9.0.300
[Host] : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
.NET 9.0 : .NET 9.0.5 (9.0.525.21509), X64 RyuJIT AVX2
Job=.NET 9.0 Runtime=.NET 9.0
Method | Mean | Error | StdDev |
---|---|---|---|
TUnit_AOT | 111.5 ms | 2.23 ms | 1.86 ms |
TUnit | 947.5 ms | 18.94 ms | 25.29 ms |
NUnit | 7,488.4 ms | 13.25 ms | 11.06 ms |
xUnit | 7,553.0 ms | 11.64 ms | 9.09 ms |
MSTest | 7,442.2 ms | 43.09 ms | 40.31 ms |
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 was computed. 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
- System.Threading.Tasks.Extensions (>= 4.6.3)
- TUnit.Assertions (>= 0.25.21)
-
net8.0
- TUnit.Assertions (>= 0.25.21)
-
net9.0
- TUnit.Assertions (>= 0.25.21)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.25.21 | 187 | 5 days ago |
0.25.6 | 130 | 9 days ago |
0.25.0 | 160 | 10 days ago |
0.24.0 | 853 | 13 days ago |
0.23.5 | 160 | 13 days ago |
0.23.0 | 97 | 15 days ago |
0.22.31 | 96 | 15 days ago |
0.22.24 | 198 | 17 days ago |
0.22.20 | 173 | 18 days ago |
0.22.12 | 194 | 20 days ago |
0.22.10 | 207 | 20 days ago |
0.22.6 | 95 | 21 days ago |
0.21.16 | 299 | 24 days ago |
0.21.13 | 175 | 25 days ago |
0.21.7 | 180 | a month ago |
0.21.1 | 219 | a month ago |
0.20.18 | 146 | a month ago |
0.20.16 | 146 | a month ago |
0.20.11 | 142 | a month ago |
0.20.4 | 103 | a month ago |