Last Updated: February 25, 2016
·
2.313K
· hannesg

SimpleCov: prevent coverage drop

SimpleCov has a neat new feature since version 0.7.0! You can now tell it to fail builds if coverage has dropped. It's pretty simple to do, just add one line to your SimpleCov config:

SimpleCov.start do
  # you old config here
  refuse_coverage_drop
end

Now run your tests. You should have a new file "coverage/.last_run.json" which contains the last test coverage. Add this to your repository and commit. Your coworkers will get failed builds whenever they let coverage decrease.

To accept small drops you can use maximum_coverage_drop instead of refuse_coverage_drop like this

SimpleCov.start do
  # you old config here
  maximum_coverage_drop 1 # = allow 1% coverage drop
end