LoginSignup
0
0

More than 1 year has passed since last update.

rails テストのGreenとRedが見やすくなるコード

Posted at

rails newを実行すると、以下のファイルが自動で生成されます。

test/test_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'

class ActiveSupport::TestCase
  parallelize(workers: :number_of_processors)
  fixtures :all
end

このファイルに以下のコードを追加します。

,
,
require 'rails/test_help'
#↓この部分です。
require "minitest/reporters" 
Minitest::Reporters.use!
,
,
class ActiveSupport::TestCase

するとテストを実行した時の表示が変わります。

Before
rails test
Running via Spring preloader in process 78091
Run options: --seed 32468

# Running:

...

Finished in 3.046170s, 0.9848 runs/s, 1.9697 assertions/s.
3 runs, 6 assertions, 0 failures, 0 errors, 0 skips
After
rails test
Running via Spring preloader in process 77920
Started with run options --seed 19772

  3/3: [======================================================] 100% Time: 00:00:03, Time: 00:00:03

Finished in 3.34285s
3 tests, 6 assertions, 0 failures, 0 errors, 0 skips #←ここの文字もハイライトが入ります。

テストが見やすくなるのでおすすめです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0