NextUnit.TestAdapter
1.17.0
See the version list below for details.
dotnet add package NextUnit.TestAdapter --version 1.17.0
NuGet\Install-Package NextUnit.TestAdapter -Version 1.17.0
<PackageReference Include="NextUnit.TestAdapter" Version="1.17.0" />
<PackageVersion Include="NextUnit.TestAdapter" Version="1.17.0" />
<PackageReference Include="NextUnit.TestAdapter" />
paket add NextUnit.TestAdapter --version 1.17.0
#r "nuget: NextUnit.TestAdapter, 1.17.0"
#:package NextUnit.TestAdapter@1.17.0
#addin nuget:?package=NextUnit.TestAdapter&version=1.17.0
#tool nuget:?package=NextUnit.TestAdapter&version=1.17.0
NextUnit
A modern, high-performance test framework for .NET 10+ with zero-reflection execution and xUnit-style assertions.
Features
- Zero-reflection execution - Source generators produce delegate-based test registry
- Familiar assertions -
Assert.Equal,Assert.True,Assert.Throws,Assert.Same,Assert.DoesNotThrow, etc. - Async tests -
Task,Task<T>,ValueTask, andValueTask<T>return types for tests and lifecycle hooks - Multi-scope lifecycle -
[Before]/[After]at Test, Class, Assembly, or Session level - Fine-grained parallelism -
[ParallelLimit(N)],[NotInParallel("key")],[ParallelGroup] - Execution priority -
[ExecutionPriority(N)]for controlling test execution order - Parameterized tests -
[Arguments],[TestData],[Matrix], and typed per-row metadata - Combined data sources -
[Values],[ValuesFromMember],[ValuesFrom<T>]with Cartesian product - Class data source -
[ClassDataSource<T>]with shared instance support - Category/Tag filtering -
[Category],[Tag]with CLI and environment variable support - Test dependencies -
[DependsOn]for ordered execution withProceedOnFailureoption - Explicit tests -
[Explicit]to exclude from default runs - Roslyn analyzers - Compile-time test validation
- Microsoft.Testing.Platform integration - Works with
dotnet run,dotnet test, and IDE test explorers - ASP.NET Core integration -
NextUnit.AspNetCorepackage for web API testing - Native AOT compatible
Quick Start
Installation
dotnet add package NextUnit
Project Configuration
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NextUnit" Version="1.17.0" />
</ItemGroup>
</Project>
Writing Tests
using NextUnit;
public class CalculatorTests
{
[Test]
public void Add_ReturnsSum()
{
Assert.Equal(4, 2 + 2);
}
[Test]
public void Divide_ThrowsOnZero()
{
Assert.Throws<DivideByZeroException>(() => { var x = 1 / 0; });
}
[Test]
[Arguments(2, 3, 5)]
[Arguments(-1, 1, 0)]
public void Add_Parameterized(int a, int b, int expected)
{
Assert.Equal(expected, a + b);
}
}
Running Tests
dotnet run --project MyProject.Tests # Run one test project
dotnet test # Run all tests when MTP is selected in global.json
With the .NET 10 SDK, dotnet test selects Microsoft.Testing.Platform at repository scope:
{
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
NextUnit repositories can copy the checked-in global.json; dotnet run needs no repository-level
configuration.
Assertions
| Category | Methods |
|---|---|
| Basic | Equal, NotEqual, True, False, Null, NotNull |
| Identity | Same, NotSame, Fail |
| Collections | Contains, DoesNotContain, Empty, NotEmpty, Single, All |
| Strings | StartsWith, EndsWith, Contains |
| Numeric | InRange, NotInRange, Equal(expected, actual, precision), Equal(expected, actual, tolerance), NotEqual(expected, actual, tolerance) |
| Exceptions | Throws<T>, ThrowsAsync<T>, DoesNotThrow, DoesNotThrowAsync |
| Advanced | Equivalent, Subset, Disjoint |
Lifecycle Hooks
public class DatabaseTests
{
[Before(LifecycleScope.Test)] // Before each test
public void Setup() { }
[After(LifecycleScope.Test)] // After each test
public void Cleanup() { }
[Before(LifecycleScope.Class)] // Once before all tests in class
public void ClassSetup() { }
[Test]
public void MyTest() { }
}
Scopes: Test, Class, Assembly, Session
Parallel Execution
[NotInParallel] // Run tests serially
public class SlowTests { }
[ParallelLimit(2)] // Max 2 concurrent tests
public class ModerateTests { }
Filtering
[Category("Integration")]
[Tag("Slow")]
public class MyTests { }
# Environment variables
NEXTUNIT_INCLUDE_CATEGORIES=Integration dotnet run --project MyProject.Tests
NEXTUNIT_EXCLUDE_TAGS=Slow dotnet run --project MyProject.Tests
Performance
The checked-in comparison suite runs 127 tests with shared bodies through native MTP executables. A 21-round cyclic comparison balances execution order across five major frameworks and Native AOT variants of NextUnit and TUnit. The current snapshot is from the PR #160 GitHub Actions run on Ubuntu 24.04:
| Framework | Version | Median | Median / NextUnit |
|---|---|---|---|
| NextUnit (AOT) | PR #160 checkout (1.15.1 assembly) | 21.51ms | 0.07x |
| TUnit (AOT) | 1.61.15 | 27.45ms | 0.09x |
| NextUnit | PR #160 checkout (1.15.1 assembly) | 311.43ms | 1.00x |
| MSTest | 4.3.2 | 438.73ms | 1.41x |
| NUnit | 4.6.1 | 512.90ms | 1.65x |
| xUnit | 3.2.2 | 551.40ms | 1.77x |
| TUnit | 1.61.15 | 555.00ms | 1.78x |
The workload is startup-heavy and machine-specific, so these ratios are not universal performance claims. See the methodology and limitations, generated results, and raw timings.
Documentation
- Getting Started
- Migration from xUnit
- ASP.NET Core Testing
- Best Practices
- Performance Analysis
- CI/CD Integration
- Changelog
Sample Projects
- Class Library Testing - Business logic testing patterns
- Console App Testing - CLI argument parsing, file processing
- Framework Tests - All NextUnit features demonstrated
- Web API Testing - ASP.NET Core integration testing with
WebApplicationTest<T>
Contributing
- Open an issue to discuss your idea
- Fork and create a feature branch
- Write tests for your changes
- Submit a PR
Note: English-only for code, comments, and documentation.
dotnet build --configuration Release
dotnet test --project samples/NextUnit.SampleTests/NextUnit.SampleTests.csproj
License
Acknowledgments
Inspired by TUnit (architecture), xUnit (assertions), and NUnit/MSTest.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Microsoft.TestPlatform.ObjectModel (>= 18.5.1)
- NextUnit.Core (>= 1.17.0)
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 |
|---|---|---|
| 1.18.0 | 39 | 7/26/2026 |
| 1.17.0 | 46 | 7/25/2026 |
| 1.16.0 | 48 | 7/25/2026 |
| 1.15.1 | 70 | 7/22/2026 |
| 1.13.0 | 682 | 1/24/2026 |
| 1.12.0 | 169 | 1/24/2026 |
| 1.11.0 | 142 | 1/24/2026 |
| 1.10.0 | 152 | 1/24/2026 |
| 1.9.0 | 153 | 1/22/2026 |
| 1.8.0 | 177 | 1/22/2026 |
| 1.7.1 | 901 | 1/19/2026 |
| 1.7.0 | 440 | 1/18/2026 |
| 1.6.9 | 155 | 1/18/2026 |
| 1.6.8 | 177 | 1/18/2026 |
| 1.6.7 | 142 | 1/18/2026 |
| 1.6.6 | 202 | 1/14/2026 |
| 1.6.5 | 151 | 1/14/2026 |
See https://github.com/crane-valley/NextUnit/blob/main/CHANGELOG.md for release notes.