3

I have a few files in my Elixir application that I'd like to exclude from the test coverage reporting. I'm not using any fancy coverage tools right now; (though I'm not closed to the possibility of using such tools) I'm just using mix test --cover right now.

How can I tell the coverage analysis tools that a given file should not be included in the coverage analysis?

Ashton Wiersdorf
  • 1,865
  • 12
  • 33

2 Answers2

4

Elixir v1.11 added :ignore_modules. See https://hexdocs.pm/mix/1.11.0/Mix.Tasks.Test.html#module-coverage.

Here's an example:

  def project do
    [
      # ...
      test_coverage: [ignore_modules: [Exclude.This, Exclude.That]]
    ]
  end
Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
2

It's not possible to do directly in Elixir at the moment. There are two libs that I know of where you can exclude specific modules.

Coverex https://github.com/alfert/coverex

Excoveralls https://github.com/parroty/excoveralls.

Check them out to see if you like them. For more information on this subject check out these links.

https://elixirforum.com/t/code-coverage-tools-for-elixir/18102/2

https://elixirforum.com/t/add-ability-to-exclude-specific-functions-modules-files-from-test-coverage-reports/15743/1

Eric
  • 175
  • 10