Today I got a nifty little GitLab feature configured for our Rails project - displaying which lines are lacking spec coverage in MR diff view.
The setup is simple, and I highly recommend you do this also. Works even on the free, self-hosted version!
Here's the official docs, I went down the Cobertura route.
Starting assumptions - you have Simplecov configured and already collecting coverage data in CI runs.
Steps remaining to do:
- Add the cobertura formatter
gem "simplecov-cobertura", require: false
- Set up multi-format formatting for Simplecov
formatters = [
# The default, human-readable HTML formatter for a coverage report
SimpleCov::Formatter::HTMLFormatter,
# Cobertura XML formatter, for GitLab MRs
defined?(SimpleCov::Formatter::CoberturaFormatter) ? SimpleCov::Formatter::CoberturaFormatter : nil
].compact
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters)
- Add this configuration to GitLab CI yaml file (adjust the path)
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: path/to/coverage.xml
Top comments (0)