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

Print seed to reproduce failure (as FsCheck allows) #179

Closed
willsam100 opened this issue Jan 30, 2019 · 3 comments · Fixed by #233
Closed

Print seed to reproduce failure (as FsCheck allows) #179

willsam100 opened this issue Jan 30, 2019 · 3 comments · Fixed by #233

Comments

@willsam100
Copy link

In FsChesk, when a test fails, the seed from the random number is printed. The seed can then be feed into the test to reproduce the same failure.

Can this be done in hedgehog? I could not see examples or any seed output.

@willsam100 willsam100 changed the title Suppling seed to reproduce failure (as FsCheck allows) Print seed to reproduce failure (as FsCheck allows) Jan 30, 2019
@moodmosaic
Copy link
Member

This isn't supported yet. If we should add support for this, it should be done through the notion of a runner config, as in the Haskell version (QC and FsCheck are doing similar, IIRC).

(FTR, in the Haskell version specifically, there's a similar discussion about being able to supply a fixed seed.)

Here in the .NET/F# version, without the notion of a runner config, one way of doing what you describe is to modify Report and report', though I think having something like a runner config sounds best.

@TysonMN
Copy link
Member

TysonMN commented Jul 2, 2020

The referenced Haskell discussion about seed fixing is motivated by wanting to make CI test runs deterministic. I have also been bitten by that behavior and would also appreciate that feature (which, as also pointed in that discussion, would be complemented by nightly builds that don't fix the seed).

My stronger motivation however is for rerunning a failed test and having it fail again (for the same reason). My understanding is that Haskell's Hedgehog achieves that behavior with a feature called recheck.

Does (the F# version of) Hedgehog have the same recheck feature? I haven't noticed it; I haven't seen any seed or similar message printed when a test fails. Instead, the message includes all the values that were generated, and I reproduce the failure by copy-pasting all those values into my test code (which is a time-consuming process).

@moodmosaic
Copy link
Member

There's no recheck yet in the .NET version—feel free to add it 👍 You may want to break this in separate steps and/or pull requests, if that's easier for you, e.g.

  1. Add recheck that runs the test once with a supplied size and seed
  2. Print the usage instructions for recheck after every test failure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants