Thanks to Jan Friedrich who pointed out the turn gem which displays what test is running, and when the test finishes, whether that test passed or failed. It’s an excellent tool that hasn’t received enough visibility.

See this comment for installation instructions.

Test::Unit doesn’t output the specifics of test failure and errors until the entire suite has completed running.

With a large enough (read: slow) suite, a lot of time can be wasted just waiting for tests to finish in order to figure out what’s actually broken.

Well, this is Ruby, so let’s just patch Test::Unit to do what we want. Add this to your test_helper.rb file, or put it somewhere handy. If there’s demand, I may package this up a bit better.

require 'test/unit/testresult'
class Test::Unit::TestResult
 
  alias :add_failure_original :add_failure
  def add_failure failure
    add_failure_original failure
    display_fault_now failure
  end
 
  alias :add_error_original :add_error
  def add_error error
    add_error_original error
    display_fault_now error
  end
 
  def display_fault_now fault
    puts ""
    puts fault.long_display
    puts ""
  end
 
end

2 Comments

  1. Jan Friedrich

    Have a look at turn which addresses the same problem and generate a nice formated output of the test results.

  2. duncanbeevers

    Beauty; hadn’t seen that gem before. Does exactly what I wanted.

    Install turn and facets to enable output colorization.

    sudo gem install turn
    sudo gem install facets # for turn output colorization

    Load turn for your tests if its available by adding this to test/test_helper.rb

    begin
      require 'turn'
    rescue LoadError
    end

Leave a Comment

Enclose code in <code lang="ruby"></code> if you care.
Preview your comment using the button below.