我将SimpleCov集成到我的Ruby项目中(简单的Ruby Gem项目,没有框架),它使用MiniTest进行测试。
这是test_helper.rb
require 'simplecov'
SimpleCov.start
require 'minitest/autorun'我所有的测试文件都有require 'test_helper.rb'。
运行所有测试(无论是从RubyMine还是使用bundle exec rake)都能正常工作,并且会创建HTML报告。
然而,它包含了...的覆盖范围。我的一个测试课程?我希望看到测试调用的所有类的覆盖率报告(在标准的/lib文件夹下)。
以下是生成的报告:
https://user-images.githubusercontent.com/6305156/80513538-df68d080-8987-11ea-9858-43a3a2673e31.png
该项目的链接:https://github.com/ruby-ee/ruby-stream-api/tree/10这是一个简单的,刚刚起步的Ruby Gem。
任何帮助都是非常感谢的。谢谢!
发布于 2020-04-29 02:09:28
我设法修好了它。SimpleCov文档指出,在需要任何应用程序代码之前,必须要求SimpleCov,并且必须发出SimpleCov.start!
我的*.gemfile中有一个require指令,因此我必须添加
require 'simplecov'
SimpleCov.start do # ommit test classes from the report
add_filter 'test'
end就在那里,而不是test_helper.rb。
https://stackoverflow.com/questions/61486705
复制相似问题