Browse files

Show location of test failures

While exception messages show a the file name/line number where the
exception was thrown, actual test failures (e.g. `refute true`) were
not displaying the location of the exception.

To expose the problem, I ran the bad test gallery with stock minitest
pride output. The __FILE__ and __LINE__ where the failed assert occured
were showing up. However, when I switched to
`Minitest::Reporters::DefaultReporter`, the failure location was gone.

I also added the ability to easily run the galleries with minitest pride
output as a way of testing the formatting of `DefaultReporter` against
stock minitest in the future.
  • Loading branch information...
1 parent 8d5b365 commit 72900775abd88df5c13dfd178dcd14a30e419330 @ntl ntl committed Apr 30, 2014
Showing with 4 additions and 2 deletions.
  1. +1 −1 lib/minitest/reporters/default_reporter.rb
  2. +3 −1 test/test_helper.rb
@@ -162,7 +162,7 @@ def message_for(test)
elsif test.error?
- "Failure:\n#{test.class}##{}:\n#{e.class}: #{e.message}"
+ "Failure:\n#{test.class}##{} [#{test.failure.location}]\n#{e.class}: #{e.message}"
@@ -11,7 +11,9 @@ class TestCase < Minitest::Test
# brittle. Consequently, there are no unit tests for them. If you'd like to run
# all the reporters sequentially on a fake test suite, run `rake gallery`.
+if ENV["REPORTER"] == "Pride"
+ require "minitest/pride"
+elsif ENV["REPORTER"]
reporter_klass = Minitest::Reporters.const_get(ENV["REPORTER"])

0 comments on commit 7290077

Please sign in to comment.