Broad Stateful Testing

We’ll start with a very wide scanning of the system to make sure the basic stuff works. This will check for simple API misunderstandings, errors that type analysis couldn’t reveal, or issues with configuration or the basic test setup.

Let’s first add the actual property declaration to our module:

 Erlang code/Bookstore/erlang/bookstore/test/prop_bookstore.erl
 -module(prop_bookstore).
 -include_lib(​"proper/include/proper.hrl"​).
 -compile(export_all).
 prop_test​() ->
  ?SETUP(​fun​() ->
  {ok, Apps} = ​application​:​ensure_all_started​(bookstore),
 fun​() -> [​application​:​stop​(App) || App <- Apps], ok ​end
 end​,
  ?FORALL(Cmds, ​commands​(?MODULE),
 begin
 bookstore_db​:​setup​(),
  {History, State, Result} ...

Get Property-Based Testing with PropEr, Erlang, and Elixir now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.