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

Dead end when shrinking #418

Closed AlexeyRaga closed 12 months ago

AlexeyRaga commented 1 year ago

I have got it in a "production" code test suit and was not able to reproduce it yet (didn't dig deep either).

Here is the exception:

System.Exception: The shrink path lead to a dead end. This should never happen.

It happened in this condition:

  1. Have a failing test
  2. Get recheck data and use it to reproduce the test
  3. Test still fails
  4. Fix the code so that test would fail differently
  5. Use the same recheck

Re-running the test fails with this exception.

TysonMN commented 1 year ago

This should never happen.

Oh! I thought it would only happen if I implemented this feature incorrectly.

  1. Fix the code so that test would fail differently.

This optimized rechecking requires the same generators to be used in the same order. Both changes to the tests or changes to the production code could cause some alternative flow to happen.

I hadn't thought of this before. Instead of saying

This should never happen.

this should say something like

Using 'recheck' is not possible because the generators have changed. Use 'check' instead.

In addition to changing this text, we can add a test that exhibits this behavior.

TysonMN commented 1 year ago

Actually, if this happens, we can automatically run check for the user. Is this better though? It could be confusing because recheck is behaving like check. But this should be ok because recheck should never be used "forever". It should just be used temporarily as part of a debugging session.

AlexeyRaga commented 1 year ago

I don't believe that it'd be fine because it may be confusing when it fails. In this case the failure will probably not be driven by that recheck string, and the user may not know about it.

LyndonGingerich commented 12 months ago

I stumbled across this when experimentally using rechecks from one test on a different test with similar generators. Should the exception message be changed?

TysonMN commented 12 months ago

Yes, thanks for the reminder. I will update the error message and include it in the upcoming release.