Posted at

Ruby on Rails - ④ minitest reporters


Gem追加

Gemfile

  gem 'rails-controller-testing', '1.0.2'

gem 'minitest', '5.10.3'
gem 'minitest-reporters', '1.1.14'
gem 'guard', '2.13.0'
gem 'guard-minitest', '2.4.4'


test/test_helper.rb修正前

ENV['RAILS_ENV'] ||= 'test'

require_relative '../config/environment'
require 'rails/test_help'

class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all

# Add more helper methods to be used by all tests here...
end


test/test_helper.rb修正前テスト実行

$rails test

  1) Failure:

StaticPagesControllerTest#test_should_get_about [/Users/akira.amagasu/Desktop/ruby/sample_app/test/controllers/static_pages_controller_test.rb:11]:
<About1 | Ruby on Rails Tutorial Sample App> expected but was
<About | Ruby on Rails Tutorial Sample App>..
Expected 0 to be >= 1.

2) Failure:
StaticPagesControllerTest#test_should_get_help [/Users/akira.amagasu/Desktop/ruby/sample_app/test/controllers/static_pages_controller_test.rb:17]:
<Help2 | Ruby on Rails Tutorial Sample App> expected but was
<Help | Ruby on Rails Tutorial Sample App>..
Expected 0 to be >= 1.

4 runs, 8 assertions, 2 failures, 0 errors, 0 skips


test/test_helper.rb修正

ENV['RAILS_ENV'] ||= 'test'

require_relative '../config/environment'
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!

class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests
# in alphabetical order.
fixtures :all

# Add more helper methods to be used by all tests here...
end


test/test_helper.rb修正後テスト実行

$rails test

少しだけ見やすくなった気がします〜