Skip to content

Instantly share code, notes, and snippets.

@dup2
Last active December 20, 2015 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dup2/6160098 to your computer and use it in GitHub Desktop.
Save dup2/6160098 to your computer and use it in GitHub Desktop.
Add a simple fail-fast option to minitest/turn/minitest-rails
# Add this to your "test_helper.rb" or "minitest_helper.rb"
#
# Example:
# FAIL_FAST=true rake minitest
#
# Add this to your Gemfile:
# group :test do
# gem 'minitest'
# gem 'minitest-rails'
# gem 'turn'
# end
# This allows for fast failure within our turn environment
# - Turn hooks into minitest with a custom runner class
# - Turn has it's own reporter which we use to output a message
class << MiniTest::Unit.runner; self; end.class_eval do
def puke(suite, test, e)
super(suite, test, e)
if ENV['FAIL_FAST'] && !e.kind_of?(MiniTest::Skip)
turn_reporter.io.puts "****** Fail fast active for tests, exiting (environment variable FAIL_FAST exists)"
exit(1)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment