Forem

Cover image for See untested code in GitLab MRs
Augusts Bautra
Augusts Bautra

Posted on

2

See untested code in GitLab MRs

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:

  1. Add the cobertura formatter
 gem "simplecov-cobertura", require: false
Enter fullscreen mode Exit fullscreen mode
  1. 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)
Enter fullscreen mode Exit fullscreen mode
  1. Add this configuration to GitLab CI yaml file (adjust the path)
  artifacts:
    reports:     
      coverage_report:
        coverage_format: cobertura
        path: path/to/coverage.xml
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more