How do I run coverage results after using meck?
tommyjcarpenter opened this issue · 2 comments
Going to use my module name of resource_handler
as an example.
I'm trying to produce coverage results after using meck
, but it shows an error Can't load module resource_handler_meck_original.
and then when I go to the coverage URL the link to that mecked module is not clickable.
Reproduction Steps
- Have a test using meck to expect a function
meck:expect(resource_handler, foo, ...)
rebar3 eunit --cover; rebar3 cover
Expected behavior
resource_handler
Coverage results work and are clickable as before I ever used meck
Observed behavior
resource_handler
Coverage results do not work; Coverage results for that module show up in the table as
| resource_handler_meck_original | 21% |
But it is not clickable to get the red/black summary of which lines were covered.
Versions
- Meck version: 0.8.6
- Erlang version: 19.3.1
hmmmm after some experimentation I seem to have resolved this by making sure I meck:unload
at the end of my test.
@tommyjcarpenter Yeah, it's not until the module is unloaded that the cover results are merged back again. Meck should unload automatically when the test process dies, but perhaps this is too late in this case and you test framework already produced the cover files.