如何将我的库的文件夹和子文件夹添加到 simplecov
生成覆盖率?
我的 SimpleCov
配置
SimpleCov.start do
add_group 'Bot', 'app/bots'
add_group 'Bot', 'lib/bot'
add_group 'Controllers', 'app/controllers'
add_group 'Models', 'app/models'
add_group 'Helpers', 'app/helpers'
add_group 'Libraries', 'lib'
end
这是我的库
├── assets
├── bot
│ ├── base_bot_logic.rb
│ ├── bot_logic.rb
│ ├── core
│ │ ├── blacklist.rb
│ │ ├── bot_core.rb
│ │ ├── broadcast.rb
│ │ ├── emoji.rb
│ │ ├── profile.rb
│ │ ├── reply.rb
│ │ ├── setup.rb
│ │ ├── state_machine.rb
│ │ └── webview.rb
│ └── geoutils
│ └── geoutils.rb
├── estrutura.txt
├── solar
│ ├── api.rb
│ ├── assistido.rb
│ ├── atendimento.rb
│ └── validation
│ └── cpf.rb
├── solar.rb
└── tasks
7 directories, 18 files
但是 SimpleCov
只能识别两个文件。
如何添加丢失的文件夹?
编辑:
我在我的 SimpleCov.start 中添加 track_files '{app,lib}/**/*.rb'
并且它识别我的文件,但不计算覆盖率。
最佳答案
虽然我错过了聚会,但我会回答
Getting started包含您问题的答案:
If SimpleCov starts after your application code is already loaded (via require), it won't be able to track your files and their coverage! The SimpleCov.start must be issued before any of your application code is required!
这样,它正确地:
require 'simplecov'
require 'yourapp'
它的不正确:
require 'yourapp'
require 'simplecov'
track_files只包含与此 glob 匹配的文件,无论它们是否被明确要求。
关于ruby - 如何使用 simplecov 包含目录和子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45737671/