本文介绍了用于 Test::Unit/rake 命令的 Rails 颜色突出显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 rails 3 项目目录中的终端中使用 rake test 命令运行测试/单元时,测试结果输出没有颜色.因此,不能一目了然.

When running test/unit using the rake test command from the terminal within a rails 3 project directory, the test result output is not coloured. Hence, it cannot be interpreted at a glance.

有没有办法像在 rspec 中那样获得结果的彩色输出?

Is there a way of getting colourised output for the results, as you can get in rspec?

>rspec --colour

推荐答案

是的,您可以使用 redgreen gem.将其包含在您的 gemfile 中:

Yes, you can use the redgreen gem. Include it in your gemfile:

group :development, :test do
  gem 'redgreen'
end

这就是 ruby​​ 1.8 所需的全部内容.如果您使用的是 1.9,则有一个解决方法.添加测试单元 gem:

And that's all you need for ruby 1.8. If you're using 1.9, there's a workaround. add the test-unit gem:

group :development, :test do
  gem 'redgreen'
  gem 'test-unit', '1.2.3
end

1.9 并不完美 - test-unit 似乎在每次 rake 任务或生成器调用后运行一个空的测试套件,这无害但很烦人.

It's not perfect with 1.9 - test-unit seems to run an empty test suite after every rake task or generator call, which is harmless but annoying.

这篇关于用于 Test::Unit/rake 命令的 Rails 颜色突出显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 04:57