January 2019
Intermediate to advanced
376 pages
8h 49m
English
As with stateful properties, we can make use of the rebar3 plugin’s templates to get a property suite within any standard Erlang project. Call the following within an existing project:
| | $ rebar3 new proper_fsm name=fsm |
| | ===> Writing test/prop_fsm.erl |
The generated file contains the prop_fsm module, a test suite that is divided in two sections: one section for the state machine property we’ll want to execute, and one for the model, which is a mix of callbacks and generators. Let’s start by looking at the property:
| | Erlang |
| | -module(prop_fsm). |
| | -include_lib("proper/include/proper.hrl"). |
| | |
| | -export([initial_state/0, initial_state_data/0, |
| | on/1, off/1, service/3, % State generators |
| | weight/3, precondition/4, ... |