k-mzqg
Last Updated: February 25, 2016
·
1.085K
· tlrdstd
9641056639707d9e4be49fc79d5e8183

SimpleCov and Cucumber

SimpleCov is a great Ruby coverage profiler for Ruby 1.9. But you don't always want it to run on every test run. (It slows down my test suite by nearly 20%.)

The official docs suggest conditionally activating SimpleCov like this:

SimpleCov.start if ENV["COVERAGE"]

and running it like this:

COVERAGE=true rake test

If you think you're clever, you might want to rename that variable to ENV['SIMPLECOV']. Problem is, the folks who wrote the Cucumber gem are also pretty clever:

if ENV['SIMPLECOV']
  require 'simplecov'

  SimpleCov.start do
    ...
  end
end

So, if you name your SimpleCov environment variable to ENV['SIMPLECOV'] and then run Cucumber tests, the Cucumber gem will hijack your SimpleCov setup and eat your lunch.

If you're still too clever to use ENV['COVERAGE'] in your app, try ENV['SIMPLE_COV'] instead.

Say Thanks
Respond