Near-perfect process-level test case isolation.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/minitest
test/minitest
.travis.yml
CHANGELOG.md
Gemfile
Gemfile.lock
README.md
Rakefile
minitest-fork_executor.gemspec

README.md

Minitest Fork Executor

Achieve near-perfect process-level test case isolation by running each and every test case in a separate process.

The gem operates at the method-level, not the class-level. This means that running a test class MyTest with test methods test_one, test_two and test_three will run each of these test_* methods in a separate process.

Build Status

Installation

Install either via Ruby Gems

gem install minitest-fork_executor

or add to Gemfile:

gem 'minitest-fork_executor', group: :test

Then configure Minitest to use it by adding the following to test_helper.rb or a similar file:

Minitest.parallel_executor = Minitest::ForkExecutor.new

Why?

The gem is motivated by my work on active_record_doctor. Each test case in the test suite defines an Active Record model dynamically and it turned out these models aren't garbage collected properly. The most likely reason for that was ActiveSupport::DescendantsTracker in Rails. The problem was compounded by testing against multiple versions of Ruby and Rails. Fixing the problem in one configuration caused it to reoccur in another one.

I wasn't able to use already-existing solutions like minitest-parallel_fork because they fork for each class but then run each test_* methods in a class in the same process. This wasn't granular enough to solve my issue and I wanted to avoid splitting my test suite into multiple single-method test classes.

Debugging and fixing the issue wasn't a top priority for me as I had already invested hours in finding a solution. My goal was to release active_record_doctor and insulate myself from similar occurences in the future.

Author

This gem is developed and maintained by Greg Navis.