No release in over a year
Easily rerun failed tests with Minitest
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

minitest-rerun-failed

Gem Version master branch CI Gem Version

Easy rerun of failed tests with minitest. Prints a list of failed tests and seed at the end of the test run to console and file. Allows for re-running the failed tests via cat'ing the outputted file.

Example screenshot

Features

  • Outputs all failed tests in short summary at end of test run.
    • To console and / or to file
    • Optionally includes line numbers
  • Lists seed of run for rerun.
  • [TODO] Executable for running only failed tests
    • Until done, use something like
      • ruby $(cat .minitest_failed_tests.txt)
      • bundle exec rails test $(cat .minitest_failed_tests.txt)

Installation

Add this line to your application's Gemfile:

gem 'minitest-rerun-failed'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install minitest-rerun-failed

Usage

Use it like any Minitest::Reporters like such:

Minitest::Reporters.use! [
  Minitest::Reporters::ProgressReporter.new, # This is just my preferred reporter. Use the one(s) you like.
  Minitest::Reporters::FailedTestsReporter.new(verbose: true, include_line_numbers: true)
]

Rails Usage

In your test_helper.rb file, add the following lines

require "minitest_rerun_failed"

Minitest::Reporters.use!(
  [Minitest::Reporters::DefaultReporter.new(color: true),
   Minitest::Reporters::FailedTestsReporter.new(verbose: true, include_line_numbers: true, output_path: "tmp")
  ],
  ENV,
  Minitest.backtrace_filter
)

Options

  • include_line_numbers: Include line numbers in outputs. Defaults to true
  • verbose: Output to stdout. Defaults to true
  • file_output: Output to file. Defaults to true
  • output_path: Path to place output files in. Defaults to '.'

Other

Why line numbers instead of test names? What if the lines change as I am fixing things?

Line numbers were much easier to implement. If you find a good way to output test names instead, please open a PR with tests to add it as an option.

As for if line numbers change, the most likely outcome is that the whole file will simply be run instead of a single test. You can also use the option include_line_numbers: false to always output whole files for greater safety.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/houen/minitest_rerun_failed.

License

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

TODO

https://stackoverflow.com/questions/19910533/minitest-rerun-only-failed-tests