Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FsCheck and NUnit integration

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?

like image 719
Lakret Avatar asked Jul 30 '12 11:07

Lakret


2 Answers

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

like image 155
roundcrisis Avatar answered Sep 24 '22 01:09

roundcrisis


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.

like image 21
Kurt Schelfthout Avatar answered Sep 27 '22 01:09

Kurt Schelfthout