tests: fix test coverage reporting for parallel testing.
* Fix simplecov clobbering test coverage reports when using parallel tests. * Generate coverage reports by default (remove $SIMPLECOV flag). * Store coverage reports in tmp/coverage/ instead of coverage/. * Enable branch coverage. ref: github.com /colszowka/simplecov/issues/718#issuecomment-538201587
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,7 +7,6 @@ config/database.yml
|
|||||||
config/danbooru_local_config.rb
|
config/danbooru_local_config.rb
|
||||||
config/deploy/*.rb
|
config/deploy/*.rb
|
||||||
config/newrelic.yml
|
config/newrelic.yml
|
||||||
coverage/
|
|
||||||
node_modules/
|
node_modules/
|
||||||
log/
|
log/
|
||||||
tmp/
|
tmp/
|
||||||
|
|||||||
6
.simplecov
Normal file
6
.simplecov
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
SimpleCov.start "rails" do
|
||||||
|
add_group "Libraries", ["app/logical", "lib"]
|
||||||
|
add_group "Presenters", "app/presenters"
|
||||||
|
enable_coverage :branch
|
||||||
|
coverage_dir "tmp/coverage"
|
||||||
|
end
|
||||||
@@ -1,13 +1,6 @@
|
|||||||
ENV["RAILS_ENV"] = "test"
|
ENV["RAILS_ENV"] = "test"
|
||||||
|
|
||||||
if ENV["SIMPLECOV"]
|
require 'simplecov'
|
||||||
require 'simplecov'
|
|
||||||
SimpleCov.start 'rails' do
|
|
||||||
add_group "Libraries", ["app/logical", "lib"]
|
|
||||||
add_group "Presenters", "app/presenters"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require File.expand_path('../config/environment', __dir__)
|
require File.expand_path('../config/environment', __dir__)
|
||||||
require 'rails/test_help'
|
require 'rails/test_help'
|
||||||
require 'cache'
|
require 'cache'
|
||||||
@@ -48,8 +41,14 @@ class ActiveSupport::TestCase
|
|||||||
mock_pool_version_service!
|
mock_pool_version_service!
|
||||||
|
|
||||||
parallelize
|
parallelize
|
||||||
parallelize_setup do
|
parallelize_setup do |worker|
|
||||||
Rails.application.load_seed
|
Rails.application.load_seed
|
||||||
|
|
||||||
|
SimpleCov.command_name "#{SimpleCov.command_name}-#{worker}"
|
||||||
|
end
|
||||||
|
|
||||||
|
parallelize_teardown do |worker|
|
||||||
|
SimpleCov.result
|
||||||
end
|
end
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
|
|||||||
Reference in New Issue
Block a user