FSharp.xUnit
1.3.0
dotnet add package FSharp.xUnit --version 1.3.0
NuGet\Install-Package FSharp.xUnit -Version 1.3.0
<PackageReference Include="FSharp.xUnit" Version="1.3.0" />
<PackageVersion Include="FSharp.xUnit" Version="1.3.0" />
<PackageReference Include="FSharp.xUnit" />
paket add FSharp.xUnit --version 1.3.0
#r "nuget: FSharp.xUnit, 1.3.0"
#:package FSharp.xUnit@1.3.0
#addin nuget:?package=FSharp.xUnit&version=1.3.0
#tool nuget:?package=FSharp.xUnit&version=1.3.0
The class library extends xunit to assert equal.
It output data in F# style.
It's easier to customize the
equals.
GetStarted
使用系统默认的相等比较器:
open FSharp.xUnit
[<Fact>]
let ``My test`` () =
Should.equal 1 1
相反的操作Should.notEqual
使用自定义的相等比较器:
.\FSharp.xUnit.Test\CustomDataExample.fs
获得了should,我们就可以进行自定义的测试了,测试的方法和上面的差不多:
.\FSharp.xUnit.Test\Test.fs
相反的操作should.notEqual
NaturalAttribute
Natural number sequence Theory is the simplest form of testing our theory with data.
type NaturalAttributeTest(output: ITestOutputHelper) =
[<Theory>]
[<Natural(4)>]
member _.``Natural Number Sequence``(i:int) =
let expect = [0;1;2;3]
let actual = [0;1;2;3]
Should.equal expect.[i] actual.[i]
[<Natural(4)>] is same as
[<Theory>]
[<InlineData(0)>]
[<InlineData(1)>]
[<InlineData(2)>]
[<InlineData(3)>]
SingleDataSource
单参数数据源
SingleDataSource向构造函数提供一个键值对列表,成员dataSource提供给MemberData特性,索引属性提供不在参数表的额外数据。
使用方法:.\FSharp.xUnit.Test\SingleDataSourceTest.fs
TupleDataSource
多参数数据源
使用方法:.\FSharp.xUnit.Test\TupleDataSourceTest.fs
ArrayDataSource
变长参数数据源
使用方法:.\FSharp.xUnit.Test\ArrayDataSourceTest.fs
ClassDataBase
open FSharp.xUnit
type MyArrays1() =
inherit ClassDataBase([
[| 3; 4 |];
[| 32; 42 |]
])
type ClassDataBaseTest(output:ITestOutputHelper) =
[<Theory>]
[<ClassData(typeof<MyArrays1>)>]
member _.v1 (a : int, b : int) =
Assert.NotEqual(a, b)
| 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
- FSharp.Core (>= 10.0.102)
- FSharp.Idioms (>= 1.5.5)
- xunit.v3.assert (>= 3.2.2)
- xunit.v3.extensibility.core (>= 3.2.2)
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.3.0 | 92 | 1/26/2026 |
| 1.2.33 | 163 | 10/17/2025 |
| 1.2.32 | 363 | 6/12/2025 |
| 1.2.31 | 179 | 2/1/2025 |
| 1.2.30 | 176 | 12/30/2024 |
| 1.2.29 | 173 | 12/30/2024 |
| 1.2.28 | 176 | 10/28/2024 |
| 1.2.27 | 207 | 5/9/2024 |
| 1.2.26 | 195 | 3/29/2024 |
| 1.2.25 | 171 | 3/6/2024 |
| 1.2.24 | 247 | 1/11/2024 |
| 1.2.23 | 214 | 1/9/2024 |
| 1.2.22 | 240 | 12/27/2023 |
| 1.2.21 | 237 | 11/19/2023 |
| 1.2.20 | 205 | 11/16/2023 |
| 1.2.19 | 187 | 11/13/2023 |
| 1.2.18 | 183 | 11/8/2023 |
| 1.2.17 | 181 | 11/8/2023 |
| 1.2.16 | 232 | 11/2/2023 |
| 1.2.15 | 199 | 11/1/2023 |
update v3