metamon/command
Stateful / model-based testing primitives.
A Command(model, real) represents one transition that can be
applied to two parallel worlds:
- model: a pure description of the expected state (typically
a record or a
Dict). Thenext_modelstep says how the command updates this expected state. - real: the system under test (a database connection, a
stateful module, an in-memory cache). The
runstep performs the command on the real world and returnsOk(Nil)on success orError(reason)when an invariant is violated.
The precondition decides whether the command can fire in the
current model state; the runner skips commands whose preconditions
are false.
See metamon/stateful for the runner that drives a list of
commands against an initial (model, real) pair.
Types
A single transition in a model-based test.
pub type Command(model, real) {
Command(
name: String,
precondition: fn(model) -> Bool,
next_model: fn(model) -> model,
run: fn(real) -> Result(Nil, String),
)
}
Constructors
-
Command( name: String, precondition: fn(model) -> Bool, next_model: fn(model) -> model, run: fn(real) -> Result(Nil, String), )
Values
pub fn always(
name name: String,
next_model next: fn(model) -> model,
run run: fn(real) -> Result(Nil, String),
) -> Command(model, real)
A command that always passes its precondition.