如何使用lib minitest或Test:Unit为单元测试着色? [英] How to color unit tests with lib minitest or Test:Unit?
问题描述
我想让单元测试在我的开发环境中输出颜色.但是,我无法使其在Linux(Debian和Ubuntu)上运行.当我包含以下库时:
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'
我得到:
/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)
由代码引起:
MiniTest::Unit.output = PrideIO.new(MiniTest::Unit.output)
我看到了一个有效的 Rspec变体.不幸的是,我对Ruby的了解还不足以看到差异.
I have seen a working Rspec variant. Unfortunately, my Ruby knowledge is not enough to see differences.
推荐答案
步骤1:使用最新版的gem(我认为它将在Ruby 1.9.3中修复)
step 1 : use the latest version of the gem (I think it will be fixed in Ruby 1.9.3)
gem install minitest
第2步:在命令行中要求最小/自豪",而不是在您的代码中
step 2 : require "minitest/pride" on the command line, not in your code
ruby -rminitest/pride your_ruby_script.rb
..,并且在您的代码中只需要'minitest/autorun'
.. and in your code simply require 'minitest/autorun'
require 'minitest/autorun'
如果您使用Rubymine,只需添加
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
这篇关于如何使用lib minitest或Test:Unit为单元测试着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!