如何从测试覆盖率分析中排除特定文件?

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

我想将我的 Elixir 应用程序中的一些文件从测试覆盖率报告中排除。我现在没有使用任何花哨的覆盖工具; (虽然我不排除使用此类工具的可能性)我现在只是在使用 mix test --cover

我如何告诉覆盖率分析工具某个给定文件不应包含在覆盖率分析中?

目前无法直接在 Elixir 中执行。我知道有两个库可以排除特定模块。

康福莱克斯 https://github.com/alfert/coverex

工作服https://github.com/parroty/excoveralls

查看它们,看看您是否喜欢它们。有关此主题的更多信息,请查看这些链接。

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

添加了 Elixir v1.11 :ignore_modules。参见 https://hexdocs.pm/mix/1.11.0/Mix.Tasks.Test.html#module-coverage

这是一个例子:

  def project do
    [
      # ...
      test_coverage: [ignore_modules: [Exclude.This, Exclude.That]]
    ]
  end