Closed teo-tsirpanis closed 6 years ago
If you register a type with Arb.Register currently will it not just work?
No. I made a generator that rises an exception and registered it. No luck.
There must be some default on the real FsCheck config that we not including when we recreate it.
My current way to do it is to override testProperty:
let testPropertyWithConfig c n t =
testPropertyWithConfig {
c with
arbitrary =
[ typeof<Arbs>
typeof<LongStringPassword>] } n t
let testProperty n t = testPropertyWithConfig FsCheckConfig.defaultConfig n t
A workaround, but still better than nothing...
I do this anyway with my common set of arbs and don't use Register.
I'm adding some code later I'll take a look.
I've taken a quick look at FsCheck code. Its nothing to do with the config being incorrect. My guess at the moment is Arb.Register isn't being called.
Will look at this later more today/tomorrow.
@teo-tsirpanis @thinkbeforecoding If you take a look at the fscheck issue fscheck/FsCheck#413 I raised this gives some explanation as to why Arb.register<_>
doesn't work.
I could add an Expecto.register<_>
and apply it to the test config but it looks like FsCheck is moving away from this kind of global state.
I think the example code above is a good solution and can be extended to give different Arbs per test grouping. It's personally what I do and don't think of it as a workaround.
Let me know what you think.
Currently, using custom generators requires creating a custom function that injects the new
Arbitrary
s to the config. I guess it can be done easier.