AnyUnit.Style.FSharp 1.2.2

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

AnyUnit.Style.FSharp

Tests as values for AnyUnit: a test is a Test built with the test { } computation expression, not an attributed method the way AnyUnit.Style.Nunit/AnyUnit.Style.Xunit/ AnyUnit.Style.FsUnit work.

When to use this - and when not to

Plain F# module-level tests do not need this style. A top-level [<Fact>] let ``adds`` () = 1 + 1 |> should equal 2 is discovered by AnyUnit.Style.Xunit as it is, and its bare should (or AnyUnit.Run.Assert.Current for any style's assertion vocabulary) asserts through the running test with real per-test counting. That is the least ceremony for the common case, and what a suite arriving from real xUnit + FsUnit already looks like. (This style predates that: it was written when a module-level let had no way to reach a test's own IAssert without a class to hang it on. AnyUnit.Run.AmbientTest closed that gap in 1.2.1.)

Reach for test { } when the test being a value is the point:

  • Composition - a Test can be built by a function, stored in a list, or wrapped by another test { } (return! inner.Run), which an attributed method can't be.
  • Start/stop resources - use/use! inside the body gives a disposable a scope that is exactly the test, with no setup/teardown attribute pair to keep in step.
  • The log as a value - let! log = log alongside let! Assert = assertion, both from the same running test.

Usage

[<assembly: AnyUnit.Style.FSharp.FSharpStyle>]
do ()

open AnyUnit.Style.FSharp.Test

// Either shape is discovered - a plain value binding, or a real
// zero-argument function (the two idiomatic ways to write "just a test,
// no parameters" in F#):
let ``adds two numbers`` = test {
    let! Assert = assertion
    Assert.Equal(4, 2 + 2)
}

let ``adds two numbers, function form`` () = test {
    let! Assert = assertion
    Assert.Equal(4, 2 + 2)
}

let! Assert = assertion binds the current test's IAssert - call straight into whichever style's assertion vocabulary you already have referenced (AnyUnit.Style.Xunit's Assert.Equal/Assert.True/..., AnyUnit.Constraints' Assert.That(x, Is.EqualTo(y)), ...): this package doesn't provide its own. let! log = AnyUnit.Style.FSharp.Test.log gets the test's ILog (captured output) the same way.

A test is discovered by its own let binding name - there's no separate description string to also keep in sync.

Parameterized tests

This style has no data attribute of its own by design (a Test is a value, not a method with parameters an attribute could sit on) - a real F# function (with real parameters, so it compiles to a genuine method, not a property) carrying another style's row attribute works instead, since Test-typed function discovery recognizes any attribute implementing AnyUnit.Run.Attributes.IRowInlineParameter:

open AnyUnit.Style.FSharp.Test
open AnyUnit.Style.Xunit // for InlineDataAttribute - any style's own row attribute works the same way

[<InlineData(1, 1)>]
[<InlineData(2, 4)>]
[<InlineData(3, 9)>]
let square (n: int) (expected: int) = test {
    let! Assert = assertion
    Assert.True(n * n = expected, $"Expected {n}*{n} = {expected}")
}

Each row runs as its own, separately-reported test - same as [TestCase]/ [InlineData] under the attribute-based styles.

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.

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.2.2 49 9/16/2026
1.2.1 59 9/16/2026
1.2.0 64 9/16/2026
1.2.0-alpha.0.6 47 9/14/2026
1.1.0 73 9/14/2026
1.0.0 80 9/12/2026