aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2015-12-19 20:04:39 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2015-12-21 07:48:53 +0900
commit4f8c36ab707b7a262cd9b37d4a71e6234d9f8f3c (patch)
treef2d24490f398647a42547244fbf766f82f8af08e /railties
parent6873db4699ac727dd27eedb0994ecdd976b40901 (diff)
downloadrails-4f8c36ab707b7a262cd9b37d4a71e6234d9f8f3c.tar.gz
rails-4f8c36ab707b7a262cd9b37d4a71e6234d9f8f3c.tar.bz2
rails-4f8c36ab707b7a262cd9b37d4a71e6234d9f8f3c.zip
display detailed information in inline reporting
The errors message only was not displayed, as if it did not use the inline reporting, modified to also information the method name and the like in error are displayed. ``` # before Failed assertion, no message given. bin/rails test test/models/user_test.rb:5 ``` ``` # after Failure: UserTest#test_the_truth: Failed assertion, no message given. bin/rails test test/models/user_test.rb:5 ```
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/test_unit/reporter.rb8
-rw-r--r--railties/test/application/test_runner_test.rb3
-rw-r--r--railties/test/generators/plugin_test_runner_test.rb3
-rw-r--r--railties/test/generators/test_runner_in_engine_test.rb3
-rw-r--r--railties/test/test_unit/reporter_test.rb9
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