Code Coverage highlighting

Note
Todo

Make it work with minitest!

  1. Install the Coverage Gutters extension and click the Watch icon added to the footer
  2. Add Simplecov and Simplecov-lcov to Gemfile:
group :test do
  gem 'simplecov'
  gem 'simplecov-lcov'
end
  1. Add the lcov formatter to SimpleCov initialization:
# spec/test_helper.rb
SimpleCov::Formatter::LcovFormatter.config do |c|
  c.report_with_single_file = true
  c.output_directory = 'coverage'
  c.lcov_file_name = 'lcov.info'
end
SimpleCov.start do
  enable_coverage :branch
  formatter SimpleCov::Formatter::MultiFormatter.new(
    [
      SimpleCov::Formatter::LcovFormatter,
      SimpleCov::Formatter::HTMLFormatter
    ]
  )
end

Voila! Now when hitting CTRL + S on any file from /app folder I do get coverage higlights in gutter:

VS Code coverage gutters for Rails application

Extension Configuration

Every project is different so it might be that you have to change some configuration options as it’s set up to support RSpec by default: