Rspec::Big::Split
Split one big RSpec test file into many smaller ones for parallel execution.
Installation
Execute this command to add gem to your application's Gemfile:
bundle add rspec-big-splitUsage
- Add
ci_split_example_groups: trueas metadata to your example groups (only for big files). - Generate tests map with:
bundle exec rspec --dry-run --format Rspec::Big::Split::Formatter --out tmp/rspec_splitter.json - Define variables like
TEST_NODE_TOTAL=20andTEST_NODE_INDEX=1in your CI/CD configuration.- Make sure that your indexing starts with
1and ends equal toTEST_NODE_TOTAL.
- Make sure that your indexing starts with
- (optional) Printout tests that will be run in current node:
bundle exec rspec-big-split tmp/rspec_splitter.json - Run tests with
bundle exec rspec $(bundle exec rspec-big-split tmp/rspec_splitter.json)to run tests on each node.
Options
- By default, this script splits tests by files into workers. If you want to split by examples, pass
--split-by-example - You can use
--add-one-on-test-node-indexto modify the index of the test node. This is useful when your CI starts indexing from0and you want to start from1.