-
Notifications
You must be signed in to change notification settings - Fork 3
Home
nialscorva edited this page Jan 30, 2011
·
4 revisions
All mock tests have the same basic form:
erlymock:start(),
erlymock:strict(module,function,[arg1,'_'],[{return,ok}]),
erlymock:stub(module,function2,[1,2,3],[{throw, myerror}]),
% initialize
erlymock:replay(),
% test
?assertMatches(ok,module:function(arg,anything)),
?assertThrow(myerror,module:function2(1,2,3)),
erlymock:verify().
- If you mock any of a module, you must mock ALL calls needed to that module. In the above example, module:function3() would be undefined, even if it's in the non-mocked module. This is expected behavior.
- Mocking a module resets code coverage statistics on that module. This is not desired, but currently there's no plan for a fix.
- Use get_socket_pair type code over erlymock_tcp when possible.
See http://sheyll.blogspot.com/2009/02/erlang-mock-erlymock.html for origins, but really the only commonality is some of the module generation code.