Open
Description
Rails version: 6.0.0 beta3
Ruby version: 2.6.1
Issue
We have configured our test helper file as below
require "simplecov"
SimpleCov.start do
add_filter "/test/"
add_group "Models", "app/models"
end
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
class ActiveSupport::TestCase
parallelize(workers: :number_of_processors)
fixtures :all
end
On executing rake test
the coverage report is incorrect even when test cases are written of the method. So this is our user model
class User < ApplicationRecord
devise :database_authenticatable, :registerable, :trackable,
:recoverable, :rememberable, :validatable
has_one_attached :avatar
validates :email, uniqueness: true
def admin?
self.role == "admin"
end
def name
"#{first_name} #{last_name}"
end
end
and the test cases we have are
def test_user_admin
user = users :admin
assert user.admin?
end
def test_user_is_not_an_admin
user = users :albert
assert_not user.admin?
end
def test_should_return_first_name_and_last_name_as_name
user = users :albert
assert_equal "Albert Smith", user.name
end
But the coverage report when parallelize
is enabled is as below
and when it is commented out the test results are all green
I tried below approaches but all of them give correct report only when parallelize
is commented:
- Simplecov with minitest Unit tests? #235 (comment)
- Created a
.simplecov
file in root directory and executedrake
. - https://github.com/colszowka/simplecov/issues?utf8=✓&q=is%3Aissue+is%3Aopen+parallel followed the issues and tried other approaches.
But I am still not able to get the correct coverage result when parallelize
is enabled.
Many thanks in advance.