Debugging Stateful Properties
Understand why the property failed in the previous lesson and take a look at the solution for the failing case.
We'll cover the following...
Understanding the bug
The previously failing property is interesting. If we look at the counterexample it looks like a regular failure where our model or the system might have been wrong, but the shrinking imploded, and the source of failure isn’t obvious. In this lesson, 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, TitleB, AuthorB, 1, 1) -> ok
find_book_by_isbn_unknown(_) -> {ok, []}
add_copy_new(_) -> {error, not_found}
find_book_by_isbn_exists(ISBNA) -> {ok, [BookA]}
return_copy_full(ISBNA) -> ok
So we might have a legitimate bug since we successfully returned a copy of a book that was never borrowed, but the shrinking isn’t helping us since it appears it can’t prune the irrelevant operations out of ...