Debugging Stateful Properties
The previously failing property is interesting. If you look at the initial counterexample, it looks like a regular failure where our model or the system might have been wrong, but the shrinking totally imploded, and the source of failure isn’t obvious. In this section, we’ll revisit the shrinking mechanism of stateful properties to understand what goes on exactly and how to get PropEr to solve our problems for us.
Let’s first compare the initial failing command set and then compare it to the shrunken one. The initial failure was caused by the following sequence of events:
- find_book_by_title_unknown(_) -> {ok, []}
- borrow_copy_unknown(_) -> {error, not_found}
- add_book_new(ISBNA, TitleA, AuthorA, 1, 1) -> ok
- add_book_new(ISBNB, ...
Get Property-Based Testing with PropEr, Erlang, and Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.