expecto
expecto copied to clipboard
Expose AsyncTest for FsCheck
It would be nice to support async FsCheck tests explicitly in the API. /cc @AnthonyLloyd
E.g.
testPropertyAsync fsCheckConfig <| fun a b c ->
async {
do! subject a b c
}
I did think about this a bit but didn't put it in in the end.
I could only make it:
testPropertyAsync fsCheckConfig <| fun (a,b,c) ->
async {
do! subject a b c
}
And I just use Async.RunSynchronously when passing to FsCheck.
FsCheck only offers sync at the moment but they are looking to add async soon.
Could be worth putting it in now if we could get the signature correct.
I was thinking we could parametise the IRunner to take a chunk to evaluate and a callback to call with the evaluated chunk. That way we don't have to tie FsCheck to the async implementation (Task/Async/Job/Alt/etc) /cc @kurtschelfthout
@kurtschelfthout @mausch What's your opinion?
Not sure it can work. Things to think about:
- Sizing. FsCheck linearly increases the size from startsize to endsize during the test. So if you want a similar size distribution of your tests as a sequential test from size 0-100, you could chop it up in 4 parallel runs as 0-24,25-49 etc. But, it's likely that larger size tests will be slower, so perhaps that's not such a great idea. Also, endsize-startsize may not be cleanly divisible by the number of parallel runs.
- Reproducibility. A run is reproducible if you have the start seed, start size and end size (generated values are dependent on seed and size). I'm not sure there is a good way to track all of that for each parallel run.
- Parts of FsCheck are not thread-safe.
See also https://github.com/fscheck/FsCheck/pull/351
Now that https://github.com/fscheck/FsCheck/pull/351#issuecomment-327929291 has been merged we should use it in Expecto. @kurtschelfthout I wasn't able to find any docs to link to? How is this feature used?
It's only merged to FsCheck 3. If you take a dependency on that, please use exact versioning constraints, as it's currently in alpha and I do expect the API to change significantly.
To use, run a property that returns Task
or Async
.