Split a big test file into multiple chunks and run them in parallel
Ruby
Latest commit 5c6c37b Oct 27, 2017
Permalink
Failed to load latest commit information.
bin Add --no-merge flag Jun 22, 2016
lib v0.7.0 Oct 27, 2017
spec Create output directory first. Oct 26, 2017
.gitignore Update for RSpec v3.1.0 Jan 12, 2015
.rspec add .rspec so order random from home is overwritten Apr 16, 2013
.travis.yml reduce builds Jun 22, 2016
Gemfile use bump gem Apr 16, 2013
Gemfile.lock v0.7.0 Oct 27, 2017
Rakefile use bump gem Apr 16, 2013
Readme.md thx for the patch Jun 22, 2016
parallel_split_test.gemspec ruby Jun 22, 2016

Readme.md

Split a big test file into multiple chunks and run them in parallel

Install

gem install parallel_split_test

Usage

1: prepare your databases

To use 1 database per test-process, add this to your config/database.yml

test:
  database: yourproject_test<%= ENV['TEST_ENV_NUMBER'] %>
  • TEST_ENV_NUMBER is '' for the first process and 2 for the 2nd, it reuses your normal test database
  • Optionally install parallel_tests to get database helper tasks like rake parallel:prepare

2: find a slow/big test file

# spec/xxx_spec.rb
require "spec_helper"

describe "X" do
  it {sleep 5}
  it {sleep 5}
  it {sleep 5}
end

3: run

parallel_split_test spec/xxx_spec.rb [regular test options]

Output

parallel_split_test spec/xx_spec.rb

Running examples in 2 processes
.

Finished in 5 seconds
1 example, 0 failures
..

Finished in 1 seconds
2 examples, 0 failures

Summary:
1 example, 0 failures
2 examples, 0 failures
Took 10.06 seconds with 2 processes

TIPS

  • use -o/--out to get unified/clean output from all processes
  • set number of processes to use with PARALLEL_SPLIT_TEST_PROCESSES environment variable
  • unify JUnit output for rspec

TODO

  • Cucumber support
  • Test::Unit / Minitest support

Authors

Contributors

Michael Grosser
michael@grosser.it
License: MIT
Build Status