Skip to Main Content
Property-Based Testing with PropEr, Erlang, and Elixir
book

Property-Based Testing with PropEr, Erlang, and Elixir

by Fred Hebert
January 2019
Intermediate to advanced content levelIntermediate to advanced
376 pages
8h 49m
English
Pragmatic Bookshelf
Content preview from Property-Based Testing with PropEr, Erlang, and Elixir

Re-centering with ?SHRINK

?SHRINK is conceptually the simplest of the two macros that can be used to impact shrinking. It is best used to pick a custom zero point toward which PropEr will try to shrink data. You can do this mainly by giving the framework a normal generator for normal cases, and then suggesting it uses other simpler generators whenever an error is discovered.

The macro takes the form ?SHRINK(DefaultGenerator, [AlternativeGenerators]) in Erlang, and shrink(default_generator, [alternative_generators]) in Elixir. The DefaultGenerator will be used for all passing tests. Once a property fails, however, ?SHRINK lets us tell PropEr that any of the alternative generators in the list are interesting ways to get simpler relevant data. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Erlang and OTP in Action

Erlang and OTP in Action

Eric Merritt, Richard Carlsson, Martin Logan
Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781680506556Errata Page