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

Testing a Basic Concurrent Cache

To use stateful tests, we’ll first need a stateful system to validate. In this section, we’ll use a cache implemented as an OTP gen_server. A common optimization pattern in Erlang is to use an ETS table for reads, and to make the writes sequential through calls to the gen_server, which ensures they’re safe. This creates a bit of contention on the write operations, so instead, we’ll try to write a cache that only uses ETS for all operations, and the gen_server’s job is just to keep the ETS table alive. The simple conceptual model—a cache handling data like a key-value store—along with an implementation dangerously accessing ETS tables concurrently makes this is a great candidate to demonstrate stateful property ...

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