I am a n00b to unit testing. I have installed FsCheck.Nunit
and NUnitTestAdapter
from Nuget, and I'm trying to do property-based-testing, largely inspired by the inestimable Scott Wlaschin.
I am using the [<Property>]
attribute, and I would like the ability to "skip" inputs that don't meet the test's requirements:
[<Property(MaxTest=10)>]
let ``Calling unzipTo with an invalid destination will yield a failure.`` badDest =
if Directory.Exists(badDest)
then // somehow skip to the next randomized input
else // do the actual test
What's the simplest way to do this?
I would prefer an answer for FsCheck/NUnit if it exists, but I would also consider any other framework whose tests can be run in Visual Studio. (I thought I saw some framework where there was a simple function to do exactly this, but I can't figure out what it was.)
I have preferred FsCheck.NUnit so far because it can generate random inputs for F# types (discriminated unions, etc) without additional work.
true
might work. I ran into this years back and the problem was overthinking the problem. Remember the test is just a function and the test driver just wants a result indicating success or failure so give it a success. – Spent