繁体   English   中英

FsUnit不会匹配异常-F#

[英]FsUnit won't match exception - F#

我正在尝试使用基于XUnit构建的FsUnit断言异常。 我已经从FsUnit网站进行了此测试:

[<Fact>]
let ``boom`` () =
    (fun () -> failwith "BOOM!" |> ignore) |> should throw typeof<System.Exception>

我正在使用Resharper 2016进行测试,但出现以下错误:

FsUnit.Xunit+MatchException
Exception of type 'FsUnit.Xunit+MatchException' was thrown.
Expected: System.Exception
Actual:   was SqlJuxtFunctionalTests.Scenarios.CompareTableScenarios+boom@22
   at SqlJuxtFunctionalTests.Scenarios.CompareTableScenarios.boom() in C:\projects\SqlJuxt\src\SqlJuxtFunctional.Tests\CompareTableScenarios.fs:line 22

我正在使用以下版本的库:

  • FSharp.Core:4.0.0.1
  • 净:4.6.2
  • FsUnit.Xunit:1.4.1.0
  • XUnit.core:2.1.0

我以为XUnit可能有问题,所以我尝试通过以下测试切换为使用基于NUnit的FsUnit:

[<Test>]
let ``boom nunit`` () =
    (fun () -> failwith "BOOM!" |> ignore) |> should throw typeof<System.Exception>

NUnit版本抛出MissingMethodException

System.MissingMethodException : Method not found: 'Void FsUnit.TopLevelOperators.should(Microsoft.FSharp.Core.FSharpFunc`2<!!0,!!1>, !!0, System.Object)'.
   at File1.boom()

任何帮助将不胜感激,因为我不知所措。

我已经弄清楚了。 为了使测试正常进行,我需要使用基于NUnit的FsUnit,并将FSharp降级以使用FSharp 3.1.2.5。 如果您使用基于NUnit和FSharp 4.0.0.1的FsUnit,则会得到可怕的MissingMethodException

我不知道为什么代码不能在FsUnit.Xunit上运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM