Polyfill.NUnit
1.0.0
dotnet add package Polyfill.NUnit --version 1.0.0
NuGet\Install-Package Polyfill.NUnit -Version 1.0.0
<PackageReference Include="Polyfill.NUnit" Version="1.0.0" />
<PackageVersion Include="Polyfill.NUnit" Version="1.0.0" />
<PackageReference Include="Polyfill.NUnit" />
paket add Polyfill.NUnit --version 1.0.0
#r "nuget: Polyfill.NUnit, 1.0.0"
#:package Polyfill.NUnit@1.0.0
#addin nuget:?package=Polyfill.NUnit&version=1.0.0
#tool nuget:?package=Polyfill.NUnit&version=1.0.0
Polyfill.NUnit
Purpose
Polyfill.NUnit lets you cross-target legacy frameworks (e.g. netstandard2.0, 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]).Is.EquivalentTo<T>(T[])generic array overload onIs, enabling collection expression usage:Is.EquivalentTo([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 ArrayEquivalence_UsesPolyfilledOverload()
{
var data = new[] { 1, 2, 3 };
Assert.That(data, Is.EquivalentTo([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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
| .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. |
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 | 89 | 1/25/2026 |
| 1.0.0-develop.15 | 42 | 1/25/2026 |
| 1.0.0-develop.13 | 139 | 12/12/2025 |
| 1.0.0-develop.12 | 714 | 12/1/2025 |
| 1.0.0-develop.11 | 257 | 11/25/2025 |
| 1.0.0-develop.10 | 147 | 11/25/2025 |
| 1.0.0-develop.9 | 157 | 11/24/2025 |
| 1.0.0-develop.8 | 155 | 11/23/2025 |