AnyUnit 1.3.0

dotnet add package AnyUnit --version 1.3.0
                    
NuGet\Install-Package AnyUnit -Version 1.3.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="AnyUnit" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AnyUnit" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="AnyUnit" />
                    
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 AnyUnit --version 1.3.0
                    
#r "nuget: AnyUnit, 1.3.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 AnyUnit@1.3.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=AnyUnit&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=AnyUnit&version=1.3.0
                    
Install as a Cake Tool

AnyUnit

Core library for AnyUnit: attribute base classes, the assertion helper, and the actual test discovery/ execution engine every style package (AnyUnit.Style.Nunit, AnyUnit.Style.Xunit, AnyUnit.Style.FSharp, AnyUnit.Style.FsUnit) and runner (AnyUnit.Runner, AnyUnit.Runner.BrowserWasm, AnyUnit.Runner.Bootstrap, AnyUnit.TestingPlatform) builds on.

You almost never reference this package directly - install a style package instead (it references this one transitively) and write tests in whichever framework's syntax that style ports. This package is what makes that syntax runnable on any platform netstandard2.0 reaches, including browser-wasm.

What lives here

  • TestFixtureAttributeBase / TestAttributeBase / TestFixtureDiscoveryAttributeBase - the base classes a style's own attributes ([TestFixture], [Test], ...) derive from, and the hooks (ParameterSets, TestInvoke, FixtureInit, ...) that let a style plug its own row-data/generator attributes and invocation behavior into one shared discovery/execution pipeline.
  • AnyUnit.Run.AssertionHelper / IAssert / AssertionException - the base a style's own assertion class derives from, and the exception types (AssertionException, IgnoreException) that drive a test's pass/fail/ignore outcome.
  • Runner / Fixture / Test / ParameterSet / Result - the engine: Runner.Create(platform, assemblies) discovers fixtures and builds a Test per parameter-set combination; RunAll executes them and reports a Result (Success/Fail/Error/Ignore/NoError) for each.

Which namespace

Since 1.3.0 (#66) the split is by audience, not by layer:

namespace for
AnyUnit what a test file names: AssertionException, IgnoreException, ResultException, IAssert, ILog, ParameterSet, TestCapabilities, [RequiresCapability]. Safe to import alongside any style.
AnyUnit.Style.Core this package's own built-in attribute style: [Test], [TestFixture], [assembly: TestFixtureDiscovery]. A style like AnyUnit.Style.Nunit is, not a layer beneath it - import one or the other, not both.
AnyUnit.Run the engine, and the extension points a style package derives: AssertionHelper, IAssertionHelper, Runner, Fixture, Test, Result. An ordinary test file does not need this.
AnyUnit.Run.Attributes what a style's attributes derive and the hook delegates they return.

The root used to hold the built-in style too, which is why using AnyUnit; was unusable from a test file and why an F# file could silently pick up the wrong [<Test>] - see Changes.md for the whole story.

Asynchronous tests

A test method may return Task, Task<T>, ValueTask, ValueTask<T> or an F# Async<'T>. The engine waits for it before deciding the test's outcome, so a failed assertion inside an async body is reported Fail (and Assert.Ignore reported Ignore) just as it would be in a synchronous one, and [Timeout] still applies - it preempts a hung await the same way it preempts a hung loop. An async Task<bool> test gets the same "returned false means fail" handling as a plain bool one.

The one platform limit is single-threaded browser-wasm: a test whose awaits all complete synchronously (the overwhelmingly common case) runs there normally, but one that genuinely suspends can never resume, since its continuation needs the thread to yield back to the browser's event loop. Declare that with [RequiresCapability(TestCapabilities.AsyncYield)] and the engine reports the test Ignored there, naming the missing facility, while it runs normally everywhere else. An undeclared one gets a clear Error rather than hanging the page.

[RequiresCapability] is read by the engine, not by any one runner, so it works in every style and every host at once. The other values: TestCapabilities.Timeouts, for tests that exist to prove [Timeout] actually fires; and TestCapabilities.Threads, for a body that blocks waiting on work that runs on another thread - Task.Run(...).Wait(), .Result, F#'s Async.RunSynchronously under a synchronization context (which Blazor has, so even a never-suspending workflow hangs there). The engine can see a returned Task; it cannot see a wait inside the body, and on single-threaded wasm nothing else can rescue it, so an undeclared one hangs the run.

TestCapabilities.FrameworkReflection is the one that is not about threads: it says every member of every framework type is present for reflection by name. Under Native AOT the compiler keeps only what the program reaches statically, so typeof(DateTime).GetProperty("Day") truthfully returns null when nothing uses Day - a test asserting on that (Has.No.Property("Day") on a DateTime, say) is answered for the wrong reason and should declare it. Reflection over the test assembly's own types is unaffected: AnyUnit.TestingPlatform roots that assembly, so those are always whole.

See AnyUnit.Runner.Bootstrap for the smallest way to actually call Runner.Create/RunAll from your own entry point, or AnyUnit.TestingPlatform for a generated dotnet test-compatible one.

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

    • No dependencies.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on AnyUnit:

Package Downloads
AnyUnit.Constraints

NUnit-style Has/Is fluent constraint syntax for AnyUnit.

AnyUnit.Style.Xunit

Roughly xUnit-compatible attributes and assertions for AnyUnit.

AnyUnit.TestingPlatform

Microsoft.Testing.Platform (MTP) adapter for AnyUnit - property-based opt-in via EnableAnyUnitRunner.

AnyUnit.Style.FsUnit

FsUnit-style F# assertions for AnyUnit.

AnyUnit.Style.Nunit

Roughly NUnit-compatible attributes and assertions for AnyUnit.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 294 9/22/2026
1.2.2 1,392 9/16/2026
1.2.1 338 9/16/2026
1.2.0 406 9/16/2026
1.2.0-alpha.0.6 78 9/14/2026
1.1.0 329 9/14/2026
1.0.0 315 9/12/2026