[erlang-questions] mockgyver -- yet another mocking library
Wed Nov 2 21:47:12 CET 2011
I'd like you to meet mockgyver -- an Erlang tool which will make it
easier to write EUnit tests that need to replace or alter (stub/mock)
the behaviour of other modules.
mockgyver aims to make that process as easy as possible with a
readable and concise syntax.
mockgyver is built around two main constructs: ?WHEN which makes it
possible to alter the behaviour of a function and another set of
macros (like ?WAS_CALLED) which check that a function was called with
a chosen set of arguments. Let's redefine pi to 4:
?WHEN(math:pi() -> 4),
4 = math:pi(),
Use pattern matching to check that a function was called with certain arguments:
?WAS_CALLED(lists:reverse([a, b, c])),
... or if you don't care about the arguments:
The library has been in use for a year for a bunch of Erlang
applications, except for a couple of recent additions.
A short tutorial as well as docs and many more examples in markdown
format on github:
More information about the erlang-questions