Add ability to exclude specific functions/modules/files from test coverage reports?

Hello! :wave:

Loving the new mix test --cover option in 1.7!

I don’t see any way to have the coverage analysis tool skip specific functions, modules, or files in its calculations, and I’m wondering whether it would be worth adding that functionality. As an example, I don’t particularly care whether def init(opts), do: opts in a plug is covered, and it’s a bit off-putting that it impacts the coverage percentage of the module.

ExCoveralls is an option, as it allows excluding files via its configuration file, but it appears that the underlying Erlang cover module might allow for a bit more granular customization via a specification file.


Hi, it seems no option for now, make a proposal at!forum/elixir-lang-core


Try this configurations in your mix.exs file

def project do
apps_path: “apps”,
# add this line
test_coverage: [ignore_modules: [MyApp.ExcludeThis, MyApp.ExcludeThat]]
Hope this helps

1 Like

Thank you, @1sarah, your suggestion worked great for me:


   def project do
         test_coverage: [ignore_modules: [MyApp.Repo]],

Awesome to know