Hi A. Sharif, thanks for a great read.
I actually wanted to reach out to you in a less public manner. But could not find a private channel to contact you through.
I was planing on showing how you could implement your examples using http://unexpected.js.org/unexpected-check/, so I created a test suite for it: https://github.com/sunesimonsen/generative-testing-example. But my example does not agree, that the last refactoring solves the problem. It still finds the counterexample handlePayment(-2, -1). I could of cause be mistaken, but I got a very talented friend of mine to review the example and he agrees that it looks like there is a problem in the example.
If that is correct, I think this shows something interesting about property based testing. The more iterations you run, the more sure you can be about correctness of the implementation — and 100 iterations is probably never enough. In addition I also think this shows that it is preferable to use a seeded random, so tests fails consistently.
Don’t take this comment the wrong way, I really enjoyed reading your post and I’m very happy people are spreading the knowledge about this powerful testing paradigm.