#104
Speeding Up Tests
11-5-2017
Summary
Slow tests can slow down your development process. Using parallel_tests, you can speed up your test suite by multiple threads and running the tests in groups.
8
rails
test
4:54
Summary
Slow tests can slow down your development process. Using parallel_tests, you can speed up your test suite by multiple threads and running the tests in groups.
8
Resources
parallel_tests - https://github.com/grosser/parallel_tests
database_cleaner - https://github.com/DatabaseCleaner/database_cleaner
Source - https://github.com/driftingruby/104-speeding-up-tests
Summary
Gemfilegroup :development, :test do
...
gem 'parallel_tests'
gem 'database_cleaner'
endconfig/database.ymltest:
<<: *default
database: db/test<%= ENV['TEST_ENV_NUMBER'] %>.sqlite3spec/support/database_cleaner.rb# Don't forget to add the below comment to your rails_helper.rb
# require 'support/database_cleaner' or
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, type: :feature) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
Could you also do a Test::Unit example?
From what I do know, there are caveat around that.