You should do something like this:
open FsCheck open FsCheck.Xunit [<Property(MaxTest=10)>] let ``Calling unzipTo with an invalid destination will yield a failure.`` badDest = (not Directory.Exists(badDest)) ==> lazy // do the actual test
The first line is a logical condition, and ==> is the user-defined operator defined by the FsCheck module. This will only result in evaluating the lazy expression if the condition on the right is true .
Consider, however, refactoring this test so that it does not depend on the file system. The file system is permanent, so it automatically creates a Persistent Fixture, which has a lot of problems to manage ; not impossible to handle, but better avoided.
This example uses FsCheck.Xunit, but IIRC FsCheck.Nunit works the same. However, you should seriously consider using FsCheck.Xunit instead of FsCheck.Nunit. The NUnit 2 extension model is unusually poor, which means that most of the glue libraries that try to extend NUnit have a lot of problems. This is not a problem with FsCheck.Nunit, but with NUnit itself, but it will prove to be in a lot of trouble for you.
source share