Skip to content

Commit

Permalink
Fix SimpleCov following issue
Browse files Browse the repository at this point in the history
simplecov-ruby/simplecov#718
Rails6のパラレルテスト対策
  • Loading branch information
universato committed Jul 10, 2021
1 parent 0c5f2ce commit 48e2708
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
3 changes: 3 additions & 0 deletions test/system/drills_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@ def login_as_basic_member
first(".problem-choice").click
assert_no_text "中断して採点する"
assert_text "採点する"
click_button "採点する"

# result
end
end
31 changes: 24 additions & 7 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
ENV['RAILS_ENV'] ||= 'test'
# [Qiita: SimpleCovとRails 6のMinitest](https://qiita.com/kazutosato/items/382afd90caf64b644e77)
# https://github.com/simplecov-ruby/simplecov/issues/718

if ENV['COVERAGE']
require 'simplecov'

require 'simplecov'
SimpleCov.start
SimpleCov.start 'rails'
end

require_relative "../config/environment"
require "rails/test_help"
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'

class ActiveSupport::TestCase
## Run tests in parallel with specified workers
# parallelize(workers: :number_of_processors)
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)

if ENV['COVERAGE']
parallelize_setup do |worker|
SimpleCov.command_name "#{SimpleCov.command_name}-#{worker}"
end

parallelize_teardown do |worker|
SimpleCov.result
end
end

# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all

# Add more helper methods to be used by all tests here...

# include FactoryBot::Syntax::Methods
end

0 comments on commit 48e2708

Please sign in to comment.