+
Skip to content

Add meck:get_state/0, meck:reset_state/0 #125

@rlipscombe

Description

@rlipscombe

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载