Thoughts on Random Number Generation - QuickCheck
This post was first published on 15 October 2020, but that site has since been shut down. Photo by Frank H Jung Part 1 of this series explored pseudo-random values—statistically random values derived from a known starting point. This article explores using random values in testing. Randomness in test invocation is common; for instance, JUnit5 provides an annotation to randomise the order of test execution . This article, however, examines a testing style using randomly generated input values to test properties of code, known as “Property Based Testing”. Why use random values in testing? Defining suitable positive and negative test cases to exercise code is often difficult. Automating the execution of many randomly selected tests covers a broader range of input values. Furthermore, recording and reporting failing tests allows for replay and debugging. Property-based testing verifies program code using a large range of relevant inputs by generatin...