在 rails 3 项目目录中的终端使用rake test命令运行 test/unit 时,测试结果输出不着色。因此,它不能一目了然地解释。
有没有办法获得结果的彩色输出,就像你可以在 rspec 中获得的那样?
>rspec --colour
在 rails 3 项目目录中的终端使用rake test命令运行 test/unit 时,测试结果输出不着色。因此,它不能一目了然地解释。
有没有办法获得结果的彩色输出,就像你可以在 rspec 中获得的那样?
>rspec --colour
I discovered that redgreen was abandoned years ago, and found this solution which works well and requires no script hacking. The output, however, shows which test is being run in real time. So it is a lot longer than built in test output. It does have nice colors.
In my Gemfile:
group :test do
gem 'turn'
end
Then run:
$ bundle install
$ rake test
The gem 'turn' works great. The caveat is that it doesn't seem to work with Mocha, due to monkey-patching issues. If you are using Mocha, you can use the redgreen gem. See instructions above in the approved answer for this question.
是的,您可以使用红绿宝石。将其包含在您的 gemfile 中:
group :development, :test do
gem 'redgreen'
end
这就是 ruby 1.8 所需要的一切。如果您使用的是 1.9,则有一种解决方法。添加测试单元gem:
group :development, :test do
gem 'redgreen'
gem 'test-unit', '1.2.3
end
1.9 并不完美 - test-unit 似乎在每次 rake 任务或生成器调用之后运行一个空的测试套件,这无害但令人讨厌。
我正在研究 Rails 5.1 / minitest,我也在寻找一种解决方案来制作报告颜色。这些 test::unit 解决方案都不起作用,所以我用谷歌搜索并看到了这个解决方案。只需添加以下内容:
# Gemfile
gem 'minitest-reporters'
# test/test_helper.rb
require "minitest/reporters"
Minitest::Reporters.use!