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

心不动则不痛 提交于 2019-12-02 23:14:50

step 1 : use the latest version of the gem (I think it will be fixed in Ruby 1.9.3)

gem install minitest

step 2 : require "minitest/pride" on the command line, not in your code

ruby -rminitest/pride your_ruby_script.rb

.. and in your code simply require 'minitest/autorun'

require 'minitest/autorun'

If you use Rubymine, just add

-rminitest

in the default configuration of the tests. => the configuration would like

-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -rminitest/pride
Colin Dean

Give turn a whirl.

Add this to your Gemfile:

group :test do
  gem 'turn', :require => false
end

See https://github.com/tenderlove/purdytest/issues/1. It seems to be a known bug with the minitest version shipped with 1.9.2. For the others, adding

gem "minitest"

at the very top of your file did the trick.

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.

I currently use purdytest with 1.9.2

Try look at this post about using turn gem for nice looking and configurable output for minitest. http://rawonrails.blogspot.com/2012/01/better-minitest-output-with-turn-gem.html

$ gem install mynyml-redgreen --source http://gemcutter.org

# in your test file
require 'redgreen'

redgreen and turn work nicely in conjunction with each other, by the way

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!