Quick Start ----------- Edit your .env.rb and modify CLOVER_DATABASE_URL for test environment: ```ruby ENV["CLOVER_DATABASE_URL"] ||= "postgres:///clover_test#{ENV["TEST_ENV_NUMBER"]}?user=clover" ``` Run below commands for running unit tests in parallel: ```bash rake setup_database[test,1] bundle exec turbo_tests ``` As the number of tests increase, I started to become uncomfortable with the unit test duration. Admittedly, our unit tests are pretty quick; they complete in ~30 seconds on my machine. However this duration is enough to break one's fast iteration cycle. If you are OK with the current unit test duration, good for you, you don't need to do anything. Everything works as before. Though you might find newly added rake task, setup_database, useful. Run it as `rake setup_database[test]` or `rake setup_database[development]` and it sets up the database from scratch. If you want to parallelize the unit test, `setup_database` has an additional parameter called `parallel`. When executed as `rake setup_database[test,1]`, the new task would create multiple databases, so that tests can be split into groups and each group can run on their own different database in parallel. Then you can run `bundle exec turbo_tests` to run all the unit tests in parallel. As a nice side note, code coverage also works, which is usually a weak link on parallel tests. Unit tests used to take ~30 seconds on my machine (`nproc`: 12), Now with the `turbo_tests`, they took ~6 seconds.
12 lines
364 B
Ruby
12 lines
364 B
Ruby
# frozen_string_literal: true
|
|
|
|
ENV["RACK_ENV"] = "test"
|
|
require_relative "../../model"
|
|
raise "test database doesn't end with test" if DB.opts[:database] && !/test\d*\z/.match?(DB.opts[:database])
|
|
|
|
require_relative "../spec_helper"
|
|
|
|
ENV["HETZNER_CONNECTION_STRING"] = "https://robot-ws.your-server.de"
|
|
ENV["HETZNER_USER"] = "user1"
|
|
ENV["HETZNER_PASSWORD"] = "pass"
|