Polyfill.NUnit
1.0.0-develop.11
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
<PackageReference Include="Polyfill.NUnit" Version="1.0.0-develop.11" />
<PackageVersion Include="Polyfill.NUnit" Version="1.0.0-develop.11" />
<PackageReference Include="Polyfill.NUnit" />
paket add Polyfill.NUnit --version 1.0.0-develop.11
#r "nuget: Polyfill.NUnit, 1.0.0-develop.11"
#:package Polyfill.NUnit@1.0.0-develop.11
#addin nuget:?package=Polyfill.NUnit&version=1.0.0-develop.11&prerelease
#tool nuget:?package=Polyfill.NUnit&version=1.0.0-develop.11&prerelease
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 onIs, enabling collection expression usage:Is.EqualTo([1, 2, 3]).using (Assert.EnterMultipleScope())for multiple assertion scopes, supersedingAssert.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.
| Product | Versions 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. |
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 |