Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a wrapper for disabling shrinking for an Arbitrary #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

neithernut
Copy link

In some cases, users may want to disable shrinking for a specific test. Consider, for example, some complex recursive data type. Naturally, we'd want values to be shrunk for most tests in order to isolate the specific sub-structure provoking the failure. However, due to the complexity we may end up with a shrinker with a certain complexity in itself. Hence, we may want to test our shrinker. For those specific tests, the very shrinking of input values performed by quickcheck could get in our way or cause failures on its own.

Previously, the only way library users could disable shrinking in such cases was to define a wrapper type (in their own code) which forwarded Arbitrary::arbitrary but not Arbitrary::shrink. We suspect that the possibility of disabling shrinking for selected tests, such as in cases described above, is not too uncommon. The wrapper pattern is easy to understand and blends in well with quickcheck. Shipping one with the library will suit the described use-cases.

The feature was requested in #285 (comment), the wrapper pattern was suggested as a user-side solution in #285 (comment).

In some cases, users may want to disable shrinking for a specific test.
Consider, for example, some complex recursive data type. Naturally, we'd
want values to be shrunk for most tests in order to isolate the specific
sub-structure provoking the failure. However, due to the complexity we
may end up with a shrinker with a certain complexity in itself. Hence,
we may want to test our shrinker. For those specific tests, the very
shrinking of input values performed by quickcheck could get in our way
or cause failures on its own.

Previously, the only way library users could disable shrinking in such
cases was to define a wrapper type (in their own code) which forwarded
`Arbitrary::arbitrary` but not `Arbitrary::shrink`. We suspect that the
possibility of disabling shrinking for selected tests, such as in cases
described above, is not too uncommon. The wrapper pattern is easy to
understand and blends in well with quickcheck. Shipping one with the
library will suit the described use-cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant