Mavryk_alpha_test_helpers.Scenario_dsl
type ('input, 'output) scenarios =
| Action : ('input ->
'output Mavryk_base.TzPervasives.tzresult Lwt.t) -> ('input, 'output)
scenarios
| Empty : ('t, 't) scenarios
| Concat : (('a, 'b) scenarios * ('b, 'c) scenarios) -> ('a, 'c) scenarios
| Branch : (('a, 'b) scenarios * ('a, 'b) scenarios) -> ('a, 'b) scenarios
| Tag : string -> ('t, 't) scenarios
| Slow : ('t, 't) scenarios
A scenario is a succession of actions. We define a branching path as a way to create multiple tests from the same point. This allows easy compositionality of behaviors with minimal code sharing. The Tag
allows to give meaningful identifiers to the branches. It is good practice to tag each case in a branch (it's not necessary, but since test names must be unique, at most one branch can remain unnamed, and even then it can create conflicting names.)
type ('input, 'output) single_scenario =
| End_scenario : ('t, 't) single_scenario
| Cons : (('input ->
't Mavryk_base.TzPervasives.tzresult Lwt.t)
* ('t, 'output) single_scenario) -> ('input, 'output) single_scenario
Unfolded scenario type
val cat_ss :
'a 'b 'c. ('a, 'b) single_scenario ->
('b, 'c) single_scenario ->
('a, 'c) single_scenario
val unfold_scenarios :
'input 'output. ('input, 'output) scenarios ->
(('input, 'output) single_scenario * string list * bool) list
val run_scenario :
'input 'output. ('input, 'output) single_scenario ->
'input ->
'output Mavryk_base.TzPervasives.tzresult Lwt.t
type test_closure = string * bool * (Tezt_mavryk.Protocol.t -> unit Lwt.t)
val unfolded_to_test :
((unit, unit) single_scenario * string list * bool) ->
test_closure
val register_test : __FILE__:string -> tags:string list -> test_closure -> unit
val register_tests :
__FILE__:string ->
tags:string list ->
test_closure list ->
unit
Useful aliases and operators
val noop : ('a, 'a) scenarios
val no_tag : ('a, 'a) scenarios
Continuation connector: execute a then b
Branching connector: creates two tests with different execution paths
val end_test : ('a, unit) scenarios
Ends the test. Dump the state, returns unit
val tests_of_scenarios :
(string * (unit, 't) scenarios) list ->
test_closure list
Transforms scenarios into tests
val exec :
('a -> 'b Mavryk_base.TzPervasives.tzresult Lwt.t) ->
('a, 'b) scenarios
Arbitrary execution
val exec_state :
(('a * 'b) -> ('c, Mavryk_base.TzPervasives.tztrace) Stdlib.result Lwt.t) ->
('a * 'b, 'd * 'e) scenarios
Execute a function that does not modify the block, only the state
val exec_unit :
('a -> (unit, Mavryk_base.TzPervasives.tztrace) Stdlib.result Lwt.t) ->
('b, 'c) scenarios
Execute a function that does not modify neither the block nor the state. Usually used for checks/asserts
fold f l
folds f
over l
, fails on empty list
fold_tag f l
folds f
over l
, l
has a tag for each of its elements. Fails on empty list.
fold_tag_f f tag l
folds f
over l
, tag
returns a tag for each element of l
. Fails on empty list.