【问题标题】:Why doesn't SimpleCov recognize my module tests?为什么 SimpleCov 不能识别我的模块测试?
【发布时间】:2020-03-20 02:42:37
【问题描述】:

我在 app/helpers 中有一个模块,我已经在 test/helpers 中为其编写了测试,但是在运行 SimpleCov 后,它显示我的 helper 的覆盖率为 0%。

我正在使用 MiniTest 运行我的测试,SimpleCov 看起来准确地报告了我的其他文件的测试覆盖率。 对于我的模块,我有:

module MyHelper
  def some_method
    ...
  end
end

对于我的测试文件,我有:

class MyHelperTest < ActiveSupport::TestCase
  describe 'when extending a class' do
    it 'should work' do
      assert some_method
    end
  end
end

知道为什么 SimpleCov 可能无法识别我的测试吗?

【问题讨论】:

  • 如果你实际使用ActionView::TestCase而不是ActiveSupport::TestCase,它是否有效?

标签: ruby-on-rails minitest simplecov


【解决方案1】:

environments/test.rb 中设置config.cache_classes = false 解决了我的报告问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 1970-01-01
    • 1970-01-01
    • 2019-01-05
    • 2013-10-19
    相关资源
    最近更新 更多