Tutorial :How to get name of the test program along with dots while running ruby test


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 test 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


# 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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »