2017-01-18 9 views
2

XUnitで構築されたFsUnitを使用して例外をアサートしようとしています。私はFsUnit websiteからこのテストを取った:FsUnitは例外と一致しません - F#

[<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 [email protected] 
    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

私はそう、私は次のテストでのNUnitに基づいてFsUnitを使用するように切り替えてみました、それはxUnitのに問題があるかもしれないと思った。

[<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() 

任意の助けをいただければ幸いです。

答えて

3

私はこれを理解しました。テストを動作させるには、NUnitに基づくFsUnitを使用し、FSharp 3.1.2.5を使用するためにFSharpをダウングレードする必要がありました。あなたがNUnitとFSharp 4.0.0.1に基づいてFsUnitを使用する場合、あなたは恐ろしいMissingMethodExceptionを取得します。

なぜコードがFsUnit.Xunitで動作しないのかわかりませんでした。

+0

[この回答](http://stackoverflow.com/questions/36238316/missingmethodexception-when-testing-a-function-that-takes-a-function-parameter/36241071#36241071)もご覧ください。 –

関連する問題