Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 1.74 KB

running-rspec-specs-in-threads.md

File metadata and controls

50 lines (37 loc) · 1.74 KB
layout title category tags
post
Running RSpec specs in parallel
Customizing your build
ruby

Semaphore lets you run RSpec specs in parallel jobs. If you want to get faster feedback from CI, we recommend using Boosters to let Semaphore automatically parallelize your Rails test suite.

Alternatively, you can try the knapsack gem. It will split tests across jobs and make sure that tests will run comparable time on each job.

Generate knapsack report

  • Ensure you've added the knapsack gem to your Gemfile.
  • Add this line at the bottom of Rakefile:
Knapsack.load_tasks if defined?(Knapsack)
  • Add at the beginning of your spec_helper.rb:
require 'knapsack'

Knapsack::Adapters::RspecAdapter.bind
  • For the first time run all specs at once with enabled report generator. Set up your build command:

After tests pass your should copy knapsack json report which is rendered at the end of rspec results. Save it into your repository as knapsack_rspec_report.json file and commit. More info about generating report you will find in knapsack docs.

Set up knapsack rspec command

Knapsack supports Semaphore ENVs SEMAPHORE_THREAD_COUNT and SEMAPHORE_CURRENT_THREAD. The only thing you need to do is set up knapsack rspec command for as many jobs as you need. Here is an example:

Tests will be split across jobs.