Prefer Minitest's location for test failures.
When running tests, the Rails test runner would report the start of the test method as the test failure. For this test: ```ruby 1 require 'test_helper 2 3 class BunnyTest < ActiveSupport::TestCase 4 test "something failing" do 5 assert false, 'This failed' 6 end 7 end ``` The runner outputs 5 instead of 4: ``` ............................................F This failed bin/rails test test/models/bunny_test.rb:5 ........ ```
This commit is contained in:
parent
49eefe123a
commit
0db310586a
@ -57,8 +57,14 @@ def fail_fast?
|
||||
end
|
||||
|
||||
def format_rerun_snippet(result)
|
||||
location, line = result.method(result.name).source_location
|
||||
"#{self.executable} #{relative_path_for(location)}:#{line}"
|
||||
# Try to extract path to assertion from backtrace.
|
||||
if result.location =~ /\[(.*)\]\z/
|
||||
assertion_path = $1
|
||||
else
|
||||
assertion_path = result.method(result.name).source_location.join(':')
|
||||
end
|
||||
|
||||
"#{self.executable} #{relative_path_for(assertion_path)}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -344,7 +344,7 @@ def test_output_inline_by_default
|
||||
create_test_file :models, 'post', pass: false
|
||||
|
||||
output = run_test_command('test/models/post_test.rb')
|
||||
assert_match %r{Running:\n\nPostTest\nF\n\nwups!\n\nbin/rails test test/models/post_test.rb:4}, output
|
||||
assert_match %r{Running:\n\nPostTest\nF\n\nwups!\n\nbin/rails test test/models/post_test.rb:6}, output
|
||||
end
|
||||
|
||||
def test_only_inline_failure_output
|
||||
|
Loading…
Reference in New Issue
Block a user