How to color unit tests with lib minitest or Test:Unit?

前端 未结 7 1306
执念已碎
执念已碎 2021-02-04 06:42

I would like to have unit tests output color in my dev environment. However, I can\'t make it work on Linux (Debian and Ubuntu). When I include the following libs:



        
7条回答
  •  广开言路
    2021-02-04 07:21

    simply add these lines to your test_helper.rb file after require 'rails/test_help'

    require "minitest/reporters"
    Minitest::Reporters.use!
    

    in your gemfile add

    gem 'minitest-reporters', '~> 1.0.7'
    

    this will get your rake test to be in red and green, but it also brings up the backtrace. to get rid of all those extra backtrace logs add this to your gemfile then bundle:

    gem 'mini_backtrace'
    

    then in config/initializers/backtrace_silencers.rb add this line to cut all the extra rvm stuff

    Rails.backtrace_cleaner.add_silencer { |line| line =~ /rvm/ }
    

    hope that works for you, let me know if you need more details.

提交回复
热议问题