-
-
Couldn't load subscription status.
- Fork 231
Description
meck:new and meck:unload are quite slow. I attempted to use fixture setup and cleanup in eunit to only call them once for the fixture:
{setup, fun fixture_setup/0, fun fixture_cleanup/1,
{foreach, fun case_setup/0, fun case_cleanup/1,
Tests}}.But then I have difficulty deleting expectations in case_cleanup: if I implement meck:delete/0, then it also removes expectations that were set up in fixture_setup and case_setup.
In particular passthrough and stub_all expectations.
So, I figure it'd be nice to be able to return an opaque term representing the current expectations at the end of case_setup. EUnit conveniently passes this to case_cleanup, where it could be restored with meck:reset_state/0.
This would save the slow meck:new and meck:unload on each case, but would guarantee that the state of the mocks was restored for the next test.