Recommended way to display/debug arbitraries?
ornamentist opened this issue · comments
Sometimes it's handy to see the kinds of values the various Arbitrary
functions are generating. This could be for debugging purposes, simple curiosity or even using the generated values in a non-testing context.
I can see a few of ways of doing this:
-
Add a
Console.log
temporarily into any function under test. -
Create a
FastCheck.Property.Sync.assertProperty
n calledDisplay
n that always returns true and contains a Console.log etc. -
Some kind of
Arbitrary
combinator that flattens the generated values into a "plain" array.
Is there a more fast-check
idiomatic way of doing this?
Sorry for not getting to this over the weekend. This isn't something I have dealt with all that much, I might verify that I'm generating the values correctly but that's separate to running fast-check on them; at that point I trust it to give me the smallest replication case possible.
As for your request, I try to avoid having code in this library that is emitted when compiled. It is what we call "zero cost"; this gives me less to maintain when fast-check changes. The big exception to this is the assertProperty
wrapper functions which are mostly there because I learned property testing with JsVerify and it offered something similar.
I suggest asking in the fast-check repo, or maybe checking the fast-check docs. If there is a feature to assist with this that I haven't made a binding for, I'm certainly happy to add one.
Thanks -- that all makes sense. I also discovered the fast-check
sample
function which is useful for separate studies of the arbitrary values being produced.