leanovate / gopter

GOlang Property TestER
MIT License
599 stars 40 forks source link

Are there resources to learn about shrinking algorithms? #38

Open CreatCodeBuild opened 6 years ago

CreatCodeBuild commented 6 years ago

Property based tests are great tools to assert properties of an API. Though I haven't done it in Go, this package looks useful.

I'm more curious about the implementation and the algorithm. Do you know any references or papers I could read?

untoldwind commented 6 years ago

There is a blog article summing up the the interna of scalacheck: https://blog.ssanj.net/posts/2017-04-12-how-does-scalacheck-shrinking-work.html

And there are several some material about QuickCheck, though I haven't read those.

au-phiware commented 6 years ago

The tests for Int64Shrinker follow a different pattern to the examples in the linked article; is this intentional? I.e. the tests shrink 10 into 0, 5, -5, 8, -8, 9, -9; whereas I would have expected 5, -5, 3, -3, 2, -2, 1, -1, 0. That is to say that the test, like Zeno's tortoise, continually advance towards the shunk value but never reach it instead of exponentially decaying towards zero.

au-phiware commented 6 years ago

I have come across this article that seems to take a similar approach as gopter (at least in the ordering/direction of the shrinking values): https://deque.blog/2017/02/10/code-your-own-quickcheck-shrink/

Is this the kind of approach that gopter takes?