diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2015-12-21 12:40:47 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2015-12-21 12:40:47 +0100 |
commit | 9aff14f1eef5771ca816d04cf725dc870f7f0dc8 (patch) | |
tree | 5310a8e36b3bced558d5e14952a4b4b5880037eb | |
parent | b06f6a1d8c7c09841c6829b788c6560b70eb36a7 (diff) | |
parent | 4f8c36ab707b7a262cd9b37d4a71e6234d9f8f3c (diff) | |
download | rails-9aff14f1eef5771ca816d04cf725dc870f7f0dc8.tar.gz rails-9aff14f1eef5771ca816d04cf725dc870f7f0dc8.tar.bz2 rails-9aff14f1eef5771ca816d04cf725dc870f7f0dc8.zip |
Merge pull request #22698 from y-yagi/display_detail_info_on_inline_report
display detailed information in inline reporting
-rw-r--r-- | railties/lib/rails/test_unit/reporter.rb | 8 | ||||
-rw-r--r-- | railties/test/application/test_runner_test.rb | 3 | ||||
-rw-r--r-- | railties/test/generators/plugin_test_runner_test.rb | 3 | ||||
-rw-r--r-- | railties/test/generators/test_runner_in_engine_test.rb | 3 | ||||
-rw-r--r-- | railties/test/test_unit/reporter_test.rb | 9 |
5 files changed, 19 insertions, 7 deletions
diff --git a/railties/lib/rails/test_unit/reporter.rb b/railties/lib/rails/test_unit/reporter.rb index 00ea32d1b8..695c67756b 100644 --- a/railties/lib/rails/test_unit/reporter.rb +++ b/railties/lib/rails/test_unit/reporter.rb @@ -12,7 +12,7 @@ module Rails if output_inline? && result.failure && (!result.skipped? || options[:verbose]) io.puts io.puts - io.puts result.failures.map(&:message) + io.puts format_failures(result) io.puts io.puts format_rerun_snippet(result) io.puts @@ -56,6 +56,12 @@ module Rails options[:fail_fast] end + def format_failures(result) + result.failures.map do |failure| + "#{failure.result_label}:\n#{result.class}##{result.name}:\n#{failure.message}\n" + end + end + def format_rerun_snippet(result) # Try to extract path to assertion from backtrace. if result.location =~ /\[(.*)\]\z/ diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 4965ab7da0..92a9b99fd8 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -344,7 +344,8 @@ module ApplicationTests 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:6}, output + expect = %r{Running:\n\nPostTest\nF\n\nFailure:\nPostTest#test_truth:\nwups!\n\nbin/rails test test/models/post_test.rb:6\n\n\n\n} + assert_match expect, output end def test_only_inline_failure_output diff --git a/railties/test/generators/plugin_test_runner_test.rb b/railties/test/generators/plugin_test_runner_test.rb index 716728819e..f0fb63c208 100644 --- a/railties/test/generators/plugin_test_runner_test.rb +++ b/railties/test/generators/plugin_test_runner_test.rb @@ -71,7 +71,8 @@ class PluginTestRunnerTest < ActiveSupport::TestCase create_test_file 'post', pass: false output = run_test_command('test/post_test.rb') - assert_match %r{Running:\n\nPostTest\nF\n\nwups!\n\nbin/test (/private)?#{plugin_path}/test/post_test.rb:6}, output + expect = %r{Running:\n\nPostTest\nF\n\nFailure:\nPostTest#test_truth:\nwups!\n\nbin/test (/private)?#{plugin_path}/test/post_test.rb:6} + assert_match expect, output end def test_only_inline_failure_output diff --git a/railties/test/generators/test_runner_in_engine_test.rb b/railties/test/generators/test_runner_in_engine_test.rb index 641c5d0835..69906b962b 100644 --- a/railties/test/generators/test_runner_in_engine_test.rb +++ b/railties/test/generators/test_runner_in_engine_test.rb @@ -17,7 +17,8 @@ class TestRunnerInEngineTest < ActiveSupport::TestCase create_test_file 'post', pass: false output = run_test_command('test/post_test.rb') - assert_match %r{Running:\n\nPostTest\nF\n\nwups!\n\nbin/rails test test/post_test.rb:6}, output + expect = %r{Running:\n\nPostTest\nF\n\nFailure:\nPostTest#test_truth:\nwups!\n\nbin/rails test test/post_test.rb:6} + assert_match expect, output end private diff --git a/railties/test/test_unit/reporter_test.rb b/railties/test/test_unit/reporter_test.rb index e517d8dd0b..3ff7cd18cd 100644 --- a/railties/test/test_unit/reporter_test.rb +++ b/railties/test/test_unit/reporter_test.rb @@ -61,14 +61,16 @@ class TestUnitReporterTest < ActiveSupport::TestCase @reporter.record(failed_test) @reporter.report - assert_match %r{\A\n\nboo\n\nbin/rails test .*test/test_unit/reporter_test.rb:\d+\n\n\z}, @output.string + expect = %r{\A\n\nFailure:\nTestUnitReporterTest::ExampleTest#woot:\nboo\n\nbin/rails test test/test_unit/reporter_test.rb:\d+\n\n\z} + assert_match expect, @output.string end test "outputs errors inline" do @reporter.record(errored_test) @reporter.report - assert_match %r{\A\n\nArgumentError: wups\n No backtrace\n\nbin/rails test .*test/test_unit/reporter_test.rb:6\n\n\z}, @output.string + expect = %r{\A\n\nError:\nTestUnitReporterTest::ExampleTest#woot:\nArgumentError: wups\n No backtrace\n\nbin/rails test .*test/test_unit/reporter_test.rb:6\n\n\z} + assert_match expect, @output.string end test "outputs skipped tests inline if verbose" do @@ -76,7 +78,8 @@ class TestUnitReporterTest < ActiveSupport::TestCase verbose.record(skipped_test) verbose.report - assert_match %r{\A\n\nskipchurches, misstemples\n\nbin/rails test .*test/test_unit/reporter_test.rb:\d+\n\n\z}, @output.string + expect = %r{\A\n\nSkipped:\nTestUnitReporterTest::ExampleTest#woot:\nskipchurches, misstemples\n\nbin/rails test test/test_unit/reporter_test.rb:\d+\n\n\z} + assert_match expect, @output.string end test "does not output rerun snippets after run" do |