Pretty test output with the Turn gem

Have you ever been annoyed that when you run tests, you only see periods, E’s and F’s; not being able to see what actually went wrong until all the tests were done?

I found this pretty gem last week, thanks to some nice people in #rubyonrails. It’s called Turn, and I am unable to find a repository for it anywhere. What it does, is update your test output as follows:

Without Turn:

Loaded suite
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader
Started
........
Finished in 0.339899 seconds.
8 tests, 8 assertions, 0 failures, 0 errors

With Turn:

Loaded suite
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader
CourseInstanceTest

test_truth                                                            PASS
CourseTest

test_truth                                                            PASS
# some output removed here
==============================================================================
pass: 8,  fail: 0,  error: 0
total: 8 tests with 8 assertions in 0.373991 seconds
==============================================================================

This way, you will be notified which tests fail right after it fails, which can save considerable time; you will be able to start fixing it before your test suite is finished (which can take quite some time I’ve noticed). As an added bonus, if you have the ‘facets‘ gem installed, it will even colorize the output.

I’ve made a small modification to the gem which allows you to specify whether or not you want to hide passed tests, since this produces quite a lot more output than the default Test::Unit output. However, I don’t have access to this modification right now, I’ll add it later.

To install:

gem install turn

To enable:

Add this to your test/test_helper.rb:

begin
  require 'turn'
rescue LoadError
  puts 'Install the Turn gem for prettier test output.'
end
Advertisements

One Response to Pretty test output with the Turn gem

  1. Sana says:

    this gem was cuasing error …i was get error on pending function in test

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: