I'm working on an application with 731 tests, and if 6 fail, I have to scroll through 731 lines to try and spot each failure so I can fix the problems.
Is there a way for minitest to print all the failed tests at the bottom? Or anything that would help me identify which tests are failing?
I am often using a large suite of tests, with some tests having fairly verbose diagnostic output. So I redirect STDOUT
and STDERR
to a log file, then grep
the file for errors like so:
bundle exec rake test:all &> test.log
grep -P -i -C3 'error|fail' test.log
Example output:
...
Failure:
FooBarTest#test_foo [/path/to/foo_bar_test.rb:64]:
Expected: 3
Actual: 4
...
Finished in 3.945161s, 13.9411 runs/s, 162.4775 assertions/s.
55 runs, 641 assertions, 1 failures, 0 errors, 0 skips
Here, grep
is run with options:
-P
: use Perl regular expressions,
-i
: case insensitive,
-C3
: print 3 lines above and 3 lines below the matching line, to provide more context of the failed tests.
Sometimes I then follow this up and look at the test log file in the editor for details on diagnostic messages, etc. But the grep
summary gives me most of the context I need in the majority of the cases.