Skip to content
No description, website, or topics provided.
Ruby Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Test against Ruby 2.7 May 28, 2020
bin first commit Jul 5, 2015
lib/minitest Bump version May 28, 2020
test Add `result` parameter to `on_consistent_failure` callback May 28, 2020
.gitignore first commit Jul 5, 2015 Add CHANGELOG entry for next version May 28, 2020
Gemfile first commit Jul 5, 2015
LICENSE.txt add LICENSE Jul 6, 2015 Use GitHub Actions only May 28, 2020
Rakefile show ruby warning Dec 31, 2016
minitest-retry.gemspec unlock dependency versions Dec 19, 2018


Re-run the test when the test fails.

Gem Version


Add this line to your application's Gemfile:

gem 'minitest-retry'

And then execute:

$ bundle

Or install it yourself as:

$ gem install minitest-retry


In your test_helper.rb file, add the following lines:

require 'minitest/retry'

Options can be specified to use! method. Can specify options are as follows:

  retry_count:  3,         # The number of times to retry. The default is 3.
  verbose: true,           # Whether or not to display the message at the time of retry. The default is true.
  io: $stdout,             # Display destination of retry when the message. The default is stdout.
  exceptions_to_retry: []  # List of exceptions that will trigger a retry (when empty, all exceptions will).


The on_failure callback is executed each time a test fails:

Minitest::Retry.on_failure do |klass, test_name, result|
  # code omitted

The on_consistent_failure callback is executed when a test consistently fails:

Minitest::Retry.on_consistent_failure do |klass, test_name, result|
  # code omitted

The on_retry callback is executed each time a test is retried:

Minitest::Retry.on_retry do |klass, test_name, retry_count, result|
  # code omitted



class Minitest::RetryTest < Minitest::Test
  def test_fail
    assert false, 'test fail'
# Running:

[MinitestRetry] retry 'test_fail' count: 1,  msg: test fail
[MinitestRetry] retry 'test_fail' count: 2,  msg: test fail
[MinitestRetry] retry 'test_fail' count: 3,  msg: test fail

Finished in 0.002479s, 403.4698 runs/s, 403.4698 assertions/s.

  1) Failure:
Minitest::RetryTest#test_fail [test/minitest/sample_test.rb:6]:
test fail


Bug reports and pull requests are welcome on GitHub at


The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.