SimpleCov:不是每次都运行,只是使用rake任务

时间:2022-05-01 02:30:56

Is there a possibility to run simplecov coverage-tool for rails just over an rake task and not every time, when running the tests?

是否有可能在rake任务上运行simplecov coverage-tool而不是每次运行测试时?

2 个解决方案

#1


7  

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

您可以使用环境变量解决此问题:

SimpleCov.start if ENV["COVERAGE"]

And then, running rake test / rspec / cucumber with

然后,运行rake test / rspec / cucumber with

$ COVERAGE=true rake test

#2


0  

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

使用rake任务运行SimpleCov的另一种方法是将设置代码从规范帮助程序移动到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

#1


7  

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

您可以使用环境变量解决此问题:

SimpleCov.start if ENV["COVERAGE"]

And then, running rake test / rspec / cucumber with

然后,运行rake test / rspec / cucumber with

$ COVERAGE=true rake test

#2


0  

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

使用rake任务运行SimpleCov的另一种方法是将设置代码从规范帮助程序移动到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