Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:

require 'minitest/autorun'
require 'minitest/unit'
require 'minitest/pride'

I get:

/usr/local/rvm/gems/ruby-1.9.2-p136/gems/minitest-2.3.1/lib/minitest/pride.rb:35:in `<top (required)>': undefined method `output' for MiniTest::Unit:Class (NoMethodError)

caused by the code:

MiniTest::Unit.output = PrideIO.new(MiniTest::Unit.output)

I have seen a working Rspec variant. Unfortunately, my Ruby knowledge is not enough to see differences.

like image 670
poseid Avatar asked Jul 07 '11 11:07

poseid


2 Answers

Give turn a whirl.

Add this to your Gemfile:

group :test do
  gem 'turn', :require => false
end
like image 134
Colin Dean Avatar answered Oct 13 '22 08:10

Colin Dean


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
like image 26
Alain Ravet Avatar answered Oct 13 '22 09:10

Alain Ravet