Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to "fail fast" when running rake test w/ minitest 5?

Is it possible to configure 'rake test' to stop running tests as soon as it hits a failure/exception?

My setup:

  • Rails 4.1
  • Minitest 5.3.4
  • Tapout (for formatting)

I'd like to start the test suite and immediately stop if a test fails -- the default behavior is to keep running all the tests which, in some cases, is too much data (especially one small bug causes a ton of tests to suddenly fail.)

I had a nice little setup going with the older version of Minitest (4.x) and the Turn gem by following this gist: (Add a simple fail-fast option to minitest/turn/minitest-rails), but I'm working on a new Rails 4.1 app right now and Turn isn't compatible with Minitest 5 (yet).

Any thoughts?

like image 773
nlh Avatar asked Oct 01 '22 18:10

nlh


2 Answers

If you are using Rails 5, try rails test -f will 'fail fast'. It means abort test run of first failure or error if you run rails test -h

like image 104
r31n4ard Avatar answered Oct 08 '22 20:10

r31n4ard


You can use this new gem with Rails 4.2 and and Minitest 5.6.1: minitest-fail-fast

like image 26
Ari Avatar answered Oct 08 '22 19:10

Ari