Today I Learned

hashrocket A Hashrocket project

Viewing your test coverage in Elixir

Curious about test coverage in your Elixir application? Mix.Tasks.Test comes with a handy --cover option.

$ mix test --cover
Generating cover results ...

Percentage | Module
   100.00% | TilexWeb.PixelController
    75.00% | Mix.Tasks.Deploy
    30.00% | TilexWeb
    68.33% | Total

By default it uses a wrapper around OTPs built in cover, however that's configurable. If you wanted to use something like excoveralls you could:

def project() do
    test_coverage: [tool: ExCoveralls]

Other niceties, like color based thresholds, can be found in the docs

See More #elixir TILs
Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.