Dennis Palmer

Elixir Developer at Erlang Solutions

Dennis first started programming 40 years ago in BASIC on the family’s TI-99/4A. He’s written code professionally using Perl, Delphi, PHP, C#, JavaScript, TypeScript, Elm, and Elixir. He was the founder of the Dallas Functional Programmers user group, which he led for five years before moving with his family to Sweden in 2019.

The Magic of Internal Shrinking for Property Based Testing

Shrinking is the real magic of property-based testing — producing a small, human-readable test case whenever a larger random case causes a test to fail. However, it can be hard to do correctly.

Traditional approaches to shrinking require the shrinking logic to know specific details about the data type being simplified. When generated values are passed through a mapping function or combined in certain ways, it can break a shrinker written with the generated data type in mind.

Internal shrinking is based on the idea that shrinking inputs produces simplified outputs. When the underlying source of randomness is reduced it causes the generators to produce simplified test cases automatically. The final reduced test case is constructed as if the generator had been lucky and produced a small, readable test case by chance.

We will explore the Decorum library, an Elixir property-based testing library with shrinking that just works.