Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minitest-retry

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minitest-retry

  • 0.2.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Minitest::Retry

Re-run the test when the test fails.

Gem Version

Installation

Add this line to your application's Gemfile:

gem 'minitest-retry'

And then execute:

$ bundle

Or install it yourself as:

$ gem install minitest-retry

Usage

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

require 'minitest/retry'
Minitest::Retry.use!

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

Minitest::Retry.use!(
  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).
  methods_to_retry:    [], # List of methods that will trigger a retry (when empty, all methods will).
  classes_to_retry:    []  # List of classes that will trigger a retry (when empty, all classes will).
)
Callbacks

The on_failure callback is executed each time a test fails:

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

The on_consistent_failure callback is executed when a test consistently fails:

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

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
end

Example


Minitest::Retry.use!

class Minitest::RetryTest < Minitest::Test
  def test_fail
    assert false, 'test fail'
  end
end
# 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
F

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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/y-yagi/minitest-retry.

License

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

FAQs

Package last updated on 15 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc