NextUnit 1.6.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NextUnit --version 1.6.0
                    
NuGet\Install-Package NextUnit -Version 1.6.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="NextUnit" Version="1.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NextUnit" Version="1.6.0" />
                    
Directory.Packages.props
<PackageReference Include="NextUnit" />
                    
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 NextUnit --version 1.6.0
                    
#r "nuget: NextUnit, 1.6.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 NextUnit@1.6.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=NextUnit&version=1.6.0
                    
Install as a Cake Addin
#tool nuget:?package=NextUnit&version=1.6.0
                    
Install as a Cake Tool

NextUnit - Modern Testing for .NET 10+

NuGet License

NextUnit is a modern, high-performance test framework for .NET 10+ that combines:

  • TUnit's modern architecture - Microsoft.Testing.Platform, Native AOT, source generators
  • xUnit's familiar assertions - Classic Assert.Equal(expected, actual), no fluent syntax

Quick Start

Installation

Simple - One Package (Recommended):

dotnet add package NextUnit

This meta-package includes everything you need:

  • NextUnit.Core - Attributes, assertions, execution engine
  • NextUnit.Generator - Source generator for zero-reflection discovery
  • NextUnit.Platform - Microsoft.Testing.Platform integration
  • Microsoft.Testing.Platform - Required platform dependency

Advanced - Individual Packages:

dotnet add package NextUnit.Core
dotnet add package NextUnit.Generator
dotnet add package NextUnit.Platform
dotnet add package Microsoft.Testing.Platform

Configure Your Test Project

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NextUnit" Version="1.6.0" />
  </ItemGroup>
</Project>

Entry Point (Optional)

The NextUnit source generator automatically creates a Program.cs entry point for your test project if one doesn't exist. You can skip this step unless you need custom configuration.

When to provide your own Program.cs:

  • Custom test application configuration
  • Additional testing extensions or middleware
  • Custom logging or diagnostic setup

If you need customization, create a Program.cs file:

using Microsoft.Testing.Platform.Builder;
using NextUnit.Platform;

var builder = await TestApplication.CreateBuilderAsync(args);
builder.AddNextUnit();
// Add your custom configuration here
using var app = await builder.BuildAsync();
return await app.RunAsync();

Write Your First Test

using NextUnit;

public class CalculatorTests
{
    [Test]
    public void Add_TwoNumbers_ReturnsSum()
    {
        var result = 2 + 2;
        Assert.Equal(4, result);
    }

    [Test]
    [Arguments(1, 2, 3)]
    [Arguments(5, 5, 10)]
    public void Add_Parameterized(int a, int b, int expected)
    {
        Assert.Equal(expected, a + b);
    }
}

Run Tests

dotnet run

Key Features

  • Zero-reflection execution - 50x faster test discovery via source generators
  • Rich assertions - Collections, strings, numerics with great error messages
  • Multi-scope lifecycle - Test, Class, Assembly scopes
  • Parallel control - [ParallelLimit], [NotInParallel]
  • Test dependencies - [DependsOn] for ordered execution
  • Native AOT compatible - Full trim and AOT support

Packages

Package Description Size
NextUnit Meta-package with all components (recommended) 4.2 KB
NextUnit.Core Core attributes, assertions, execution engine 32.1 KB
NextUnit.Generator Source generator for test discovery 20.7 KB
NextUnit.Platform Microsoft.Testing.Platform integration 15.4 KB

Total Size: 72.4 KB (ultra-lightweight!)

Documentation

What's Different from xUnit?

Feature xUnit NextUnit
Test Attribute [Fact] [Test] (clearer)
Parameterized [Theory] + [InlineData] [Test] + [Arguments]
Discovery Runtime reflection Source generator (50x faster)
Parallelism Limited control Fine-grained with [ParallelLimit]
Lifecycle Constructor + IDisposable Multi-scope [Before]/[After]
AOT Support Limited Full Native AOT compatible

Performance

  • Test Discovery: ~2ms for 1,000 tests (50x faster than xUnit)
  • Execution: ~540ms for 1,000 tests with parallel execution
  • Per-test Overhead: ~0.54ms per simple test
  • Throughput: 1,852 tests/second
  • Framework Memory: ~5MB baseline
  • Zero reflection in execution path

Contributing

Contributions welcome! See our Contributing Guide.

License

MIT License

Acknowledgments

Inspired by:

  • TUnit - Modern architecture, source generators
  • xUnit - Ergonomic assertions, proven patterns
  • NUnit/MSTest - Battle-tested reliability

Built with love for .NET 10+ developers who want modern performance with familiar syntax

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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.13.0 276 1/24/2026
1.12.0 140 1/24/2026
1.11.0 116 1/24/2026
1.10.0 121 1/24/2026
1.9.0 122 1/22/2026
1.8.0 151 1/22/2026
1.7.1 874 1/19/2026
1.7.0 415 1/18/2026
1.6.9 135 1/18/2026
1.6.8 160 1/18/2026
1.6.7 122 1/18/2026
1.6.6 176 1/14/2026
1.6.2 1,152 12/20/2025
1.6.1 328 12/15/2025
1.6.0 512 12/14/2025
1.5.0 726 12/10/2025
1.4.0 934 12/10/2025
Loading failed