当然,下面的两个测试失败了。但为什么错误消息显示两个相同的预期值?有没有办法只显示一个?
myTest
返回Expected: <B> or <B> But was: <A>
myTest2
返回Expected: <{ N = 2 }> or <{ N = 2 }> But was: <{ N = 1 }>
Expected: <B> But was: <A>
这在使用普通 NUnit 时按预期工作(例如)。
当然,在处理更复杂的类型时,这会变得非常糟糕。
测试.cs:
namespace Blah
open FsUnit
open NUnit.Framework
module Tests =
type MyDU = A | B
type MyRecord = { N: int }
[<Test>]
let myTest ()=
A |> should equal B
[<Test>]
let myTest2 ()=
{ N = 1 } |> should equal { N = 2 }
项目文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Tests.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="5.0.2" />
<PackageReference Include="FsUnit" Version="4.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
</ItemGroup>
</Project>