hedgehogqa / fsharp-hedgehog

Release with confidence, state-of-the-art property testing for .NET.
https://hedgehogqa.github.io/fsharp-hedgehog/
Other
271 stars 31 forks source link

Shrink with timeout instead of number #425

Open cmeeren opened 1 year ago

cmeeren commented 1 year ago

I came across a blog post on property testing that used jqwik. It seems to have some nice functionality that would be great to have in Hedgehog.

One useful feature is shrinking for a certain amount of time (search this page for ShrinkingMode.BOUNDED): If a property fails, jqwik tries to shrink for (by defaut) up to 10 seconds. I'm not sure about the current Hedgehog functionality, but I am guessing it has a maximum number of shrinks instead of a time-based limit. The result is that, for complex inputs, the values may not be fully shrunk. When a property fails, I would find it much more useful to have the inputs be shrunk as much as possible, and I would have no problem waiting, say, up to 10 seconds for Hedgehog to produce the most shrunk values possible.

moodmosaic commented 1 year ago

Perhaps @TysonMN is the one to comment on this 👀

TysonMN commented 1 year ago

The current default behavior is to shrink at most 100 times. That value can be set to a larger number, but shrinking cannot currently be restricted (only) by time. This seems like a reasonable request. However, I would prefer to see a motivating use case before implementing.

cmeeren commented 1 year ago

I consider what I said to be a motivating use case:

The result is that, for complex inputs, the values may not be fully shrunk.

I have experienced this from time to time. I don't have any code I am able to share, though.

This has previously been reported in #223.

TysonMN commented 1 year ago

I want an actual test someone wrote that doesn't fully shrink. I want to run the test myself. Issue #223 is blocked until you recall the test you had written.

It is ok if the test is "sanitized" to remove or replace intellectual property from an employer.

TysonMN commented 1 year ago

The current default behavior is to shrink at most 100 times.

Actually, the default behavior is to stop shrinking if 100 values are discarded.

cmeeren commented 1 year ago

I will try to keep it in mind and post such an example here the next time it happens. May be a while.