Classic Docs
Docs Navigation

Running Minitest tests in parallel

Semaphore lets you run Minitest tests in parallel jobs. If you want to get faster feedback from CI then you can try 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 at the beginning of your test_helper.rb:
require 'knapsack'

knapsack_adapter = Knapsack::Adapters::MinitestAdapter.bind
  • For the first time run all tests 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 minitest results. Save it into your repository as knapsack_minitest_report.json file and commit. More info about generating report you will find in knapsack docs.

# Set up knapsack minitest command

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

Tests will be split across jobs.

Semaphore Docs are open source — Edit on GitHub


Occasional lightweight product and blog updates. Unsubscribe at any time.

2009-2021 © Rendered Text. All rights reserved. Terms of Service, Privacy policy, Security.