sb logoToday I Learned

Measuring test coverage with Mix

I am accustomed to using tools like codecov and coveralls to measure test coverage. But Mix has built-in test coverage calculations.

mix test --cover
Generating cover results ...

Percentage | Module
-----------|--------------------------
    75.00% | Chameleon
   100.00% | Chameleon.CMYK
   100.00% | Chameleon.Color.CMYK.Any
...
   100.00% | Chameleon.PantoneToHex
    98.15% | Chameleon.RGB
   100.00% | Chameleon.RGB888
    87.50% | Chameleon.Util
   100.00% | ChameleonTest.Case
-----------|--------------------------
    97.25% | Total

It prints out a great summary, but also generates HTML files that details which lines are covered, and which are not.

open cover/Elixir.Chameleon.Util.html