Polyfill.NUnit 1.0.0-develop.11

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

Polyfill.NUnit

Purpose

Polyfill.NUnit lets you cross-target legacy frameworks (e.g. netcoreapp3.1, net5.0) while beginning to use selected features that NUnit 4 introduces. NUnit 4 raises its minimum supported target frameworks and will never support net5.0, so this library provides a transitional window: Keep older TFMs in your multi-target matrix for maintenance while adopting newer, more expressive NUnit syntax.

What it provides

Focused, source-compatible polyfills that mimic NUnit 4 surface area where:

  • The API is additive (safe forward removal once you move fully to NUnit 4)
  • Behavior can match existing NUnit 4 functionality exactly, but does not guarantee it
  • NUnit analyzers (and general modernization efforts) encourage newer syntax (e.g. collection expressions) that would otherwise not compile on NUnit 3

Currently included:

  • Is.EqualTo<T>(T[]) generic array overload on Is, enabling collection expression usage: Is.EqualTo([1, 2, 3]).
  • using (Assert.EnterMultipleScope()) for multiple assertion scopes, superseding Assert.Multiple.

Requirements

The test project must use at least C# 14 for the new extensions feature.

Example

Use NUnit 4 like you usually would, even on legacy target frameworks!

using NUnit.Framework;

[TestFixture]
public class SampleTests
{
    [Test]
    public void ArrayEquality_UsesPolyfilledOverload()
    {
        var data = new[] { 1, 2, 3 };
        Assert.That(data, Is.EqualTo([1, 2, 3]));
    }

    [Test]
    public void MultipleAsserts_CanUseEnterMultipleScope()
    {
        var data = new[] { 1, 2, 3 };
        using (Assert.EnterMultipleScope())
        {
            Assert.That(data, Is.EqualTo([1, 2, 3]));
            Assert.That(data, Is.EquivalentTo([3, 2, 1]));
        }
    }
}

Setup

Include the Polyfill.NUnit NuGet package in your test project that targets legacy frameworks. This can either be done in the project file or a shared Directory.Build.props file.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>netcoreapp3.1;net5.0;net10.0</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NUnit" Version="4.4.0" />
    
  </ItemGroup>

  <ItemGroup>
  </ItemGroup>

  
  <ItemGroup Condition="'$(TargetFramework)'=='net5.0' Or '$(TargetFramework)'=='netcoreapp3.1'">
    <PackageReference Update="NUnit" Version="3.14" />
    <PackageReference Include="Polyfill.NUnit" Version="1.0.0" />
  </ItemGroup>

</Project>

Credits

All credits for the original NUnit design, concepts, and implementation belongs to the NUnit team. This project is unaffiliated and purely a compatibility aid and is very much slightly adopted code from the original NUnit source.

https://github.com/nunit/nunit

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 was computed.  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 was computed.  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 netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

  • net5.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.0.0 88 1/25/2026
1.0.0-develop.15 41 1/25/2026
1.0.0-develop.13 138 12/12/2025
1.0.0-develop.12 713 12/1/2025
1.0.0-develop.11 256 11/25/2025
1.0.0-develop.10 146 11/25/2025
1.0.0-develop.9 156 11/24/2025
1.0.0-develop.8 154 11/23/2025