rails 4 simpecov 丢失的文件 [英] rails 4 simpecov missing files

查看:41
本文介绍了rails 4 simpecov 丢失的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是测试的忠实粉丝,当我运行当前的覆盖率报告时,我注意到 simplecov 没有接收到我的 lib 子文件夹,其中包含 .rb 文件.

I am a huge fan of testing and when I run my current coverage reports I noticed that my lib sub folders with .rb files are not being picked up by simplecov.

这是我在我的 spec_helper.rb 文件中的设置:

Here is my setup in my spec_helper.rb file:

if ENV['COVERAGE']
  require 'simplecov'
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
    SimpleCov::Formatter::HTMLFormatter
  ]
  SimpleCov.minimum_coverage 90
  SimpleCov.start do
    coverage_dir 'tmp/coverage'
    add_filter '/.bundle/'
    add_filter '/spec/'
    add_filter '/config/'
    add_group 'Models', 'app/models'
    add_group 'Controllers', 'app/controllers'
    add_group 'Services', 'app/services'
    add_group 'Helpers', 'app/helpers'
    add_group 'Lib', 'lib'
    add_group 'Mailers', 'app/mailers'
    add_group "Long Files" do |src_file|
      src_file.lines.count > 100
    end
    add_group 'Ignored Code' do |src_file|
      open(src_file.filename).grep(/:nocov:/).any?
    end
  end
end

虽然我今天在那个文件夹中没有太多东西,但我想弄清楚为什么它们没有进来.目前,我希望在我的报告中看到我的 lib/modules 文件夹b/c 它有一个 helper_functions.rb 文件供 rake 内部使用.

While I do not have much in that folder today, I am trying to figure out why they are not coming in. Currently, I would have expected to see my lib/modules folder in my reports b/c it has a helper_functions.rb file used by rake inside.

=> git 问题 #351

此外,我尝试了这些解决方案但没有成功:

Also, I have tried these solutions with no luck:

推荐答案

我曾经遇到过类似的问题,结果是在 SimpleCov 启动之前加载了一些未报告的代码.例如,如果您通过 rake 命令运行测试,如果您的 Rakefile 在调用 spec_helper.rb 脚本之前拉入了一些库,则不会报告这些库.

I once had a similar issue and it turned out that some of the unreported code was being loaded before SimpleCov was started. For example, if you are running your tests via a rake command, if your Rakefile pulls in some libraries before invoking the spec_helper.rb script, those libraries won't get reported.

这篇关于rails 4 simpecov 丢失的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆