3

On case of test failure hypothesis suggests to add decorator @reproduce_faliure("") to easily reproduce and debug a particular failure. This is very convenient for the usual pipeline Test -> Fix failure with debugger -> Look for the next failures.

Do we have something similar in rusts proptest library?

We need either implemented solution from proptest or some custom code to implement this pipeline i.g. with serde.

Dimitrius
  • 564
  • 6
  • 21
  • I'm not sure if this exactly addresses your issue, but `proptest` will by default persist failures and replay them on subsequent runs to prevent spurious passing tests, c.f. [the book](https://altsysrq.github.io/proptest-book/proptest/failure-persistence.html#failure-persistence). – isaactfa Nov 16 '22 at 16:09
  • @isaactfa It does so, but if you try to replay the test with debugger, you will see a bunch of completely unrelated runs before it finally comes to the breaking example. – Dimitrius Nov 16 '22 at 16:17
  • I presume that's because `proptest` persists failures by saving the seed that generated them so when they get rerun, all the cases that seed produces will be generated again until the failing one. I feel like the thing you want would end up behaving the same way. – isaactfa Nov 16 '22 at 16:27
  • Hypothesis has an exact representation for each example encoded in base64 string. You add the decorator to the test and it runs exactly one example. And always fails. Either with DidNotReproduce exception or with test Exception. We can try to achieve the same at least using serde. – Dimitrius Nov 16 '22 at 16:48
  • The link I've posted above outlines why the authors of `proptest` didn't opt for that strategy. So you'll have to implement that yourself. – isaactfa Nov 16 '22 at 16:51
  • Hypothesis stores seed, but allows to run one particular test for that seed. If we are not using serde, we can do it the same way. – Dimitrius Nov 16 '22 at 17:26

0 Answers0