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

Thinking Outside the Box

The examples we’ve seen so far can be impressive, but they mostly aimed to directly impact the way data was generated. Targeted properties can help in much more creative ways, but it tends to require approaching problems differently from most other types of testing. For this section, we’ll use targeted properties to weed out a bug we suspect might lie in a quicksort function.

If you’re familiar with quicksort, you know it’s a fast sorting algorithm—especially in imperative languages where in-place sorting can be done to save on memory. It’s also one of the most often used algorithms when demonstrating list comprehensions. The official Erlang documentation gives an example looking like this:

 Erlang code/TargetedProperties/erlang/target/test/prop_target.erl ...
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