When I run my tests using rake I see dots as the tests are progressing. What I want is the name of the test program before the dots. I am getting some warnings but am not sure which t开发者_运维技巧est is throwing the warning. Getting the test name will help me immensely.
you should have a look at github.com/TwP/turn -- it produces colorized output, outputs PASS/FAIL per test method and, most importantly, it shows you the relevant failure/error right after it has occured, not "after all the dots".
The Readme at Github has all the relevant info.
You probably want
ruby test/test_name.rb --verbose
and to see other options for test/unit, you can run
ruby test/test_name.rb --help
The test-unit gem adds better failing messages that will identify which test file had the failure. Just include it in your Gemfile
group :development do
gem 'test-unit'
end
FYI, to get colorized output you can run the default rake task with TESTOPTS
bundle exec rake test TESTOPTS='--use-color'
Or you can have even more control by creating a custom rake task that uses Rake::TestTask
https://github.com/jimweirich/rake/blob/master/lib/rake/testtask.rb
# lib/tasks/my_custom_test_runner.rake
require 'rake/testtask'
Rake::TestTask.new("test:my_custom_test_runner") do |t|
t.libs << "test"
t.test_files = FileList['test/test*.rb']
t.verbose = true
t.opts = "--use-color"
end
Setting t.verbose = true
will include in the output, the command used to run your tests based on the rake task you defined.
精彩评论