I want to integrate FsCheck tests with NUnit tests. Specifically, when I declare several FsCheck properties, I want them to be visible and runnable from the VS runner. I have found the following description of xUnit usage alongside FsCheck (under "Implementing IRunner to integrate FsCheck with mb|x|N|cs|Unit"), but this is not what I want. Is there a way to do it?
Can you elaborate why using that is not what you want? That's the way to feed the result of an FsCheck test back to NUnit. You'd write FsCheck tests much like normal NUnit tests, and attribute them with a Test attribute (or whatever the name is in NUnit).
If you want tighter integration with NUnit, you'll have to become familiar with the NUnit plugin model. NUnit integration is next up on my todo list. For an example of how to integrate with XUnit.NET, have a look at the FsCheck.Xunit project in the source. From the FsCheck side, it should be fairly similar, but NUnit's plugin model is fairly different from XUnit's.
Just for reference, there is now a FsCheck.Nunit integration nuget package It works for F# 3.1 only (at the moment)
Usage:
Add the nuget package (it will add also a file into the project that is expected)
[<Property>]
let maxLe (x:float) y =
(x <= y) ==> (lazy (max x y = y))
if you want verbose output you can add Verbose = true to the Property attribute
Can you elaborate why using that is not what you want? That's the way to feed the result of an FsCheck test back to NUnit. You'd write FsCheck tests much like normal NUnit tests, and attribute them with a Test attribute (or whatever the name is in NUnit).
If you want tighter integration with NUnit, you'll have to become familiar with the NUnit plugin model. NUnit integration is next up on my todo list. For an example of how to integrate with XUnit.NET, have a look at the FsCheck.Xunit project in the source. From the FsCheck side, it should be fairly similar, but NUnit's plugin model is fairly different from XUnit's.
© 2022 - 2024 — McMap. All rights reserved.