quicktheories / QuickTheories

Property based testing for Java 8
Apache License 2.0
505 stars 51 forks source link

Adds support for frequency generators #51

Closed jonmeredith closed 5 years ago

jonmeredith commented 5 years ago

Introduces a new generator frequency that works similar to oneOf, but each generator passed to it also gets a weight, and the resulting output is generated in proportion to the weights supplied.

Also includes a version with no shrink point which is useful for generating command sequences.

jlink commented 5 years ago

You might want to consider a change to the method' name. In other pbt libraries (e.g. jqwik, scalacheck), frequency is used to choose between instances of the type to generate.

In this case you want to choose between generators, similiar to what oneOf is doing. That's why I suggest frequencyOf as name. This would match jqwik's naming: https://jqwik.net/docs/current/user-guide.html#randomly-choosing-among-arbitraries