Lately I’ve been learning a ton more about Elixir and really working towards refactoring and hardening the system.
On my current project, I’ve got about 200 tests that exercise various parts of the system. Lately though, I’ve been trying to analyze which parts of the system aren’t being covered, and of course, theres tools to help with that.
Getting started is a breeze, check the readme for that. I’ll cover it briefly for a bit here, my modifying our
1 2 3 4 5 6 7
After setup, running
mix test --cover generates some reports in your projects
./cover folder – with
modules.html. These give you your standard coverage reports with lines covered / ratio covered.
For my project, I had quite a bit of generated files using exprotobuf. The coverage report was getting butchered from not using these many files in my tests.
According to the docs, we can add a keyword for
ignore_modules in the keyword list
test_coverage and the coverage reports will ignore those modules.
However, for my generated list of modules, I had quite the growing list to ignore and it quickly became unwieldy to put that list of modules in my
Since we can’t access other modules from our mix file, I had a quick solution. I created a
.coverignore file in the project directory, lumped in all the modules I wanted to ignore (from the
modules.html generated file) and put them all in the
I ensured all the modules I wanted to ignore were all newline delimited (
From there, I modified my
mix.exs file as such:
1 2 3 4 5 6 7 8
Boom, that does it! Now we’ve got a manageable list of modules to ignore in a separate file so we can keep our mix file clean.
All in all,
coverex is a great module, and I would suggest using it if you do not want to ship data to coveralls.
Hope this helps, happy coding. Cheers!