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

时间:2019-05-07 17:46:42

标签: elixir mix

我的Elixir应用程序中有一些文件要从测试覆盖率报告中排除。我现在不使用任何花哨的报道工具; (尽管我对使用此类工具的可能性还不满意)我现在只是在使用mix test --cover

如何告诉覆盖率分析工具不应将给定文件包括在覆盖率分析中?

2 个答案:

答案 0 :(得分:1)

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

Coverex 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

答案 1 :(得分: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