vwhuqq
Last Updated: February 25, 2016
·
6.209K
· weimeng
0cd59490b4ca72fbb0e784796f4034db

Using Code Climate's new test reporter together with Coveralls and SimpleCov's HTML Formatter

Code Climate just announced the addition of test coverage reporting to their suite of code quality tools. Exciting!

As I expected, Code Climate's codeclimate-test-reporter gem was using SimpleCov to power their test coverage reporting.

At work, we're already using Coveralls to track test coverage over time. In addition, I'm using SimpleCov's HTMLFormatter to generate local test coverage reports so I don't have to wait on our CI provider for coverage reports.

Thankfully, it was fairly simple to add Code Climate's own formatter into my SimpleCov workflow.

Add codeclimate-test-reporter to your Gemfile and at the top of spec_helper.rb:

require 'codeclimate-test-reporter'
require 'simplecov'
require 'coveralls'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
  Coveralls::SimpleCov::Formatter,
  SimpleCov::Formatter::HTMLFormatter,
  CodeClimate::TestReporter::Formatter
]
SimpleCov.start 'rails'

Done!

You can also find any updates to the code here: https://gist.github.com/weimeng/6290044

Say Thanks
Respond

2 Responses
Add your response

9364
C001a49670b21737ef0113b89074bc67

I used webmock for mocking external requests, so I had a problem with it blocking coveralls and codeclimate from submitting the reports, so I added this in:

RSpec.configure do |config|
  ...
  config.after(:suite) do
    WebMock.disable!
  end
end

In addition, I amended your code such that only if the ENV variable is provided for the respective services do I add it to the formatter. See gist: https://gist.github.com/jaryl/6554599#file-spec_helper-rb

over 1 year ago ·
13882
A0d82d974ea90955a1e2c20123e5e59f
over 1 year ago ·
Awesome Job

D8c7bb04 bfe7 11e7 9a4a 7b76a32c6bdb
Full Stack Developer
·
Amsterdam, the Netherlands
·
Full Time