How can I exclude a particular file from test coverage analysis?

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?


  • Elixir v1.11 added :ignore_modules

    From the v15 docs (with a more comprehensive explanation):

    :ignore_modules - modules to ignore from generating reports and in summaries. It is a list of module names as atoms and regular expressions that are matched against the module names.

    Here's an example:

      def project do
          # ...
          test_coverage: [ignore_modules: [Exclude.This, Exclude.That, ~r/\.LiveView\./]]