jjh42 / mock

Mocking library for Elixir language
MIT License
639 stars 81 forks source link

:meck.unload on exit #101

Closed kelostrada closed 5 years ago

kelostrada commented 5 years ago

When running tests using setup_with_mock the mocks aren't actually unloaded fast enough (or maybe not at all) and sometimes they pass through to other tests (which don't want the mocks to be active at all). All the tests I did were on async: false and this still happened. Then I noticed you don't unload explicitly the mocks so hence the PR. I unload the mocks globally using :meck.unload() but I figure you don't want to use the mocks in different tests (setting them in one test and unloading in different) as the loading/unloading is indeterministic. I'm convinced it's pretty safe to unload all the mocks at the end of the test every time the test is finished. This happens in ExUnit's on_exit.

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4d61eb656f93de5d6b7f8f19c094eb5cd0141496 on Gamecode-HQ:fix_setup_with_mocks into f5b8a3781c2f8c5e6a7ea8819ba1db78c85963ea on jjh42:master.

Olshansk commented 5 years ago

Seeing how all the tests in mock_setup_test.exs pass, it looks pretty safe to me as well.

Thanks for your contribution!

liskin commented 4 years ago

@Olshansk This PR fixes an issue that we're experiencing. Can you please make a release with this fix? Thanks a lot!

Olshansk commented 4 years ago

Done!