FsCheck and NUnit integration
Asked Answered
E

2

5

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?

Esau answered 30/7, 2012 at 11:45 Comment(0)
F
3

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.

Farinose answered 10/8, 2012 at 14:10 Comment(0)
W
6

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

Welladvised answered 6/8, 2014 at 11:27 Comment(0)
F
3

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.

Farinose answered 10/8, 2012 at 14:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.