The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Verbose output by default with Test::Unit 2

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
Verbose output by default with Test::Unit 2 Posted: Jul 27, 2010 11:51 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: Verbose output by default with Test::Unit 2
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
With test-unit 2.x you can set global configuration options for how your tests run. Global configuration options for test-unit 2 are controlled by your $HOME/.test-unit.yml file.

For example, you can set your runner and verbose output like so:
runner: console
console_options:
  arguments: --verbose

This is what I do now. I don't like the default output for test-unit because it isn't informative. It's just a bunch of dots. When one fails, you have to sit there and wait for the tests to complete before you can see what failed. This can lead to Testing Rage.

So, instead of output that looks like this:
Started
.F........

You can see what test failed right away:
Started
TC_FileWC: 
  test_an_invalid_option_raises_an_error:		.: (0.000498)
  test_intentional_failure:				F: (0.004532)
  test_wc_accepts_specific_optional_arguments:		.: (0.000674)
  test_wc_method_basic_functionality:			.: (0.000712)
  test_wc_requires_at_least_on_argument:		.: (0.000416)
  test_wc_with_bytes_option_returns_the_expected_result:.: (0.000406)
  test_wc_with_chars_option_returns_the_expected_result:.: (0.000407)
  test_wc_with_lines_option_returns_the_expected_result:.: (0.000366)
  test_wc_with_no_option_returns_expected_results:	.: (0.001137)
  test_wc_with_words_option_returns_the_expected_result:.: (0.000381)

As you can see, instead of waiting for the test suite to complete to determine what test failed, I can see right away that it was the "test_intentional_failure" test that failed. I can also see how long it took to run each test.

This is a superior approach not only because of nicer output, it's a better way to find bad tests. On more than one occasion I've written a test that would hang (blocking IO, infinite loop, whatever), but I couldn't tell which test was hanging with the standard test-unit output. This solves that.

(Warning: test-unit 2.0.9 and earlier had a bug where it was looking for .test-unit.xml by mistake)

Read: Verbose output by default with Test::Unit 2

Topic: Clojure: Destructuring Previous Topic   Next Topic Topic: OSCON 2010

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use