Skip to content
Ole Morten Amundsen edited this page Oct 5, 2018 · 6 revisions

With SIMPLECOV simplecov -- by a grateful user

To print the simplecov report after ALL threads are finished, to stop printing for each thread, do:

spec_helper.rb

if ENV['COVERAGE'] == 'true'
  require 'simplecov'
  require 'simplecov-console'
  SimpleCov.formatter = SimpleCov::Formatter::Console
  SimpleCov.start 'rails'
  if ENV['TEST_ENV_NUMBER'] # parallel specs
    SimpleCov.at_exit do
      result = SimpleCov.result
      result.format! if ParallelTests.number_of_running_processes <= 1
    end
  end
end

RSpec.configure do |config|
 ...

gems:

group :test do
  gem 'simplecov'
  gem 'simplecov-console'

Extras: Reduce noise in the output:

spec_helper.rb or rails_helper.rb


RSpec.configure do |config|
  ...
  # mute noise for parallel tests
  config.silence_filter_announcements = true if ENV['TEST_ENV_NUMBER']

!! Add your own experience / gotchas !!

Clone this wiki locally