Property testing
An alternative method of testing that is popular in frameworks, such as QuickCheck
in Haskell and ScalaCheck
in Scala, is the idea of property testing. Property testing is aimed at testing a single property of a function at a time. For example, when concatenating two strings together, the length property should always remain consistent as the sum of the original two lengths. This is in contrast to the normal style of testing, which is example-driven.
Note
Note that a property in this case doesn't refer to the properties of objects, as in fields or members. Instead, it refers to some invariant or predicate that should be true.
Given that we are going to test that a property holds for multiple input values, it follows that we would want to use as many different values as possible. For this reason, property-based testing is often associated with the automatic generation of input values. In KotlinTest, these values are provided through the aptly named generators.
To use a...