AnyUnit.Style.FSharp
1.2.0
See the version list below for details.
dotnet add package AnyUnit.Style.FSharp --version 1.2.0
NuGet\Install-Package AnyUnit.Style.FSharp -Version 1.2.0
<PackageReference Include="AnyUnit.Style.FSharp" Version="1.2.0" />
<PackageVersion Include="AnyUnit.Style.FSharp" Version="1.2.0" />
<PackageReference Include="AnyUnit.Style.FSharp" />
paket add AnyUnit.Style.FSharp --version 1.2.0
#r "nuget: AnyUnit.Style.FSharp, 1.2.0"
#:package AnyUnit.Style.FSharp@1.2.0
#addin nuget:?package=AnyUnit.Style.FSharp&version=1.2.0
#tool nuget:?package=AnyUnit.Style.FSharp&version=1.2.0
AnyUnit.Style.FSharp
F#'s own idiomatic, value-based test style for
AnyUnit - a test is a Test value
built with the test { } computation expression, not a [Test]-
attributed instance method the way AnyUnit.Style.Nunit/
AnyUnit.Style.Xunit/AnyUnit.Style.FsUnit all work. If your F# test
suite already reaches for real NUnit/xUnit's attribute style, use one of
those instead - reach for this one when a top-level let reads more
naturally than a class full of [Test] methods.
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 | Versions 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. |
-
.NETStandard 2.0
- AnyUnit (>= 1.2.0)
- FSharp.Core (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.