开发者

SimpleCov: Not run every time, just with rake task

开发者 https://www.devze.com 2023-02-14 11:48 出处:网络
Is there a possibility to run simplecov coverage-tool for rails just over a开发者_开发百科n rake task and not every time, when running the tests? You can sort of work around this using an environment

Is there a possibility to run simplecov coverage-tool for rails just over a开发者_开发百科n rake task and not every time, when running the tests?


You can sort of work around this using an environment variable:

SimpleCov.start if ENV["COVERAGE"]

And then, running rake test / rspec / cucumber with

$ COVERAGE=true rake test


Another way to run SimpleCov with rake task only is to move the setup code out of the spec helper into Rakefile.

# Rakefile

... # normal Rakefile stuff


if defined? RSpec
  task(:spec).clear

  RSpec::Core::RakeTask.new(:spec) do |t|
    require 'simplecov'
    SimpleCov.start 'rails'
  end
end
0

精彩评论

暂无评论...
验证码 换一张
取 消