本文介绍了Simplecov 报告忽略/app 目录中的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 simplecov 来衡量我的 Rails 4.0.11 应用程序的覆盖率.我使用 Ruby 2.0.0.我注意到 simplecov 忽略了/app 的一些子文件夹,我不知道为什么.

I use simplecov to measure coverage for my Rails 4.0.11 app. I use Ruby 2.0.0. I noticed that some subfolders of /app are ignored by simplecov and I can't figure out why.

test_helper.rb:
require 'simplecov'
SimpleCov.start 'rails'

ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)

在阅读了一些可能有帮助的帖子后,我尝试升级到 Ruby 2.1,但仍有一些子文件夹被忽略.我还尝试将 SimpleCov.start 移动到我项目根目录下的 .simplecov 文件中,但问题仍然存在.我还尝试删除 rails 配置并自己添加过滤器和组,但被忽略的只是空的.

I have tried upgrading to Ruby 2.1 after reading some posts that that might help, but still some subfolders are being ignored. I also tried to move the SimpleCov.start into a .simplecov file at the root of my project, but the problem persists. I also tried to remove the rails configuration and add filters and groups myself, but the ignored ones just turn up empty.

像/mailers、/serializers、/presenters 这样的文件夹都被忽略了.它确实适用于/models 和/controllers.

Folder like /mailers, /serializers, /presenters are all ignored. It does pick up on /models and /controllers.

推荐答案

我遇到了同样的问题.在您的 rails 环境/test.rb 中制作 config.eager_load = true.这将在应用启动时加载每个 ruby​​ 文件.

I had the same issue. in your rails environments/test.rb make config.eager_load = true. this will load every ruby files while app booting.

这篇关于Simplecov 报告忽略/app 目录中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 19:07