Parallel Coverage
Rails engine that gets SimpleCov up and running for you in a parallelized test suite.
This gem sets an initializer to run the coverage measurement instead of running it directly at the beginning of the tests themselves, so it is more suitable for a fully featured tests suite (i.e. with integration tests) rather than unit tests only.
Installation
Add this lines to your application's Gemfile:
group :test do
gem 'parallel_coverage'
end
Usage
Run your tests through CLI with the COVERAGE
environment variable set to true:
COVERAGE=true bin/rails test:system test
The default SimpleCov config passed to the SimpleCov.start 'rails'
call is the following:
track_files 'app/**/*.rb'
add_filter '/bin/'
add_filter '/config/'
add_filter '/db/'
add_filter '/lib/'
add_filter '/test/'
add_filter 'vendor'
add_filter 'node_modules'
add_filter '/Rakefile'
add_group 'Services', 'app/services'
We assume that admin controllers are not critical enought to be tracked in the coverage, but if you need to, you can override those settings by adding a config/initializers/coverage.rb
with:
ParallelCoverage.simple_cov_config = proc do
add_filter '/my/awesome/filter1'
add_filter '/my/awesome/filter2'
...
end
Keep in mind that by doing this you will totally disable the default config, so you'll have to put it back in your config/initializers/coverage.rb
if you want to extend the config.
Release
Before all, configure your credentials for RubyGems :
- Login to RubyGems
- Create a token which have rights to push gems (https://rubygems.org/profile/api_keys)
- Add it to your config:
echo ":rubygems_api_key: YOUR_API_KEY" >> ~/.gem/credentials
You just have to run default command:
rake release
Else, to publish a new version of this gem, you'll need to build it with
gem build parallel_coverage.gemspec
and then push it manually:
gem push parallel_coverage-X.X.X.gem
License
The gem is available as open source under the terms of the MIT License. Copyright 2021 Codeur SARL.