Module Mock

type ('args, 'ret) t

A mock is something that can be used in place of function.

('args, 'ret) t is similar to 'args -> 'ret except that:

val make : name:string ‑> ('args'rett

Build an unconfigured mock. Calling an unconfigured mock will raise an exception that contains the name of the mock.

val name : ('args'rett ‑> string

Retrieve the name of a mock.

type 'a side_effect

What a mock can evaluate to.

val not_configured : 'a side_effect

Evaluation is not possible. call will raise Mock_non_configured.

val return : 'a ‑> 'a side_effect

Return a value.

val raise : exn ‑> 'a side_effect

Raise an exception.

val configure : ('args'rett ‑> 'ret side_effect ‑> unit

Define what a mock should return.

val call : ('args'rett ‑> 'args ‑> 'ret

Call the mock:

exception Mock_not_configured of string

call will raise this exception if the mock has not been configured.

val recorded_calls : ('args'rett ‑> 'args list

Return the list of arguments this mock has received. The list is in the same order as the calls.