1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix reporter test and verbose mode

This commit is contained in:
Arthur Neves 2015-02-03 21:54:50 -05:00 committed by Yves Senn
parent 6ccbeb458a
commit f10c7e1849
2 changed files with 8 additions and 10 deletions

View file

@ -3,7 +3,7 @@ require "minitest"
module Rails module Rails
class TestUnitReporter < Minitest::StatisticsReporter class TestUnitReporter < Minitest::StatisticsReporter
def report def report
return if passed? return if results.empty?
io.puts io.puts
io.puts "Failed tests:" io.puts "Failed tests:"
io.puts io.puts

View file

@ -12,7 +12,7 @@ class TestUnitReporterTest < ActiveSupport::TestCase
end end
test "prints rerun snippet to run a single failed test" do test "prints rerun snippet to run a single failed test" do
@reporter.results << failed_test @reporter.record(failed_test)
@reporter.report @reporter.report
assert_match %r{^bin/rails test .*test/test_unit/reporter_test.rb:6$}, @output.string assert_match %r{^bin/rails test .*test/test_unit/reporter_test.rb:6$}, @output.string
@ -20,26 +20,24 @@ class TestUnitReporterTest < ActiveSupport::TestCase
end end
test "prints rerun snippet for every failed test" do test "prints rerun snippet for every failed test" do
@reporter.results << failed_test @reporter.record(failed_test)
@reporter.results << failed_test @reporter.record(failed_test)
@reporter.results << failed_test @reporter.record(failed_test)
@reporter.report @reporter.report
assert_rerun_snippet_count 3 assert_rerun_snippet_count 3
end end
test "does not print snippet for successful and skipped tests" do test "does not print snippet for successful and skipped tests" do
skip "confirm the expected behavior with Arthur" @reporter.record(passing_test)
@reporter.results << passing_test @reporter.record(skipped_test)
@reporter.results << skipped_test
@reporter.report @reporter.report
assert_rerun_snippet_count 0 assert_rerun_snippet_count 0
end end
test "prints rerun snippet for skipped tests if run in verbose mode" do test "prints rerun snippet for skipped tests if run in verbose mode" do
skip "confirm the expected behavior with Arthur"
verbose = Rails::TestUnitReporter.new @output, verbose: true verbose = Rails::TestUnitReporter.new @output, verbose: true
verbose.results << skipped_test verbose.record(skipped_test)
verbose.report verbose.report
assert_rerun_snippet_count 1 assert_rerun_snippet_count 1