The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
ZenTest and unit_diff

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
Ryan Davis

Posts: 651
Nickname: zenspider
Registered: Oct, 2004

Ryan Davis is a ruby nerd.
ZenTest and unit_diff Posted: Jun 3, 2005 2:36 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Ryan Davis.
Original Post: ZenTest and unit_diff
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby

Advertisement

What do you do when you change something and your unit tests break? You look at what broke, right? But, what do you do when you look at it and you can't find out what is wrong because the text is just too big?

I just had that happen. Can you quickly tell what is broken? I can't. It looks like this:

% ruby  ./TestZenTest.rb 
Requiring ZenTest
Loaded suite ./TestZenTest
Started
.................F...............
Finished in 0.186974 seconds.

  1) Failure:
test_klasses_equals(TestZenTest) [./TestZenTest.rb:468]:
<{"Something"=>
  {"equal?"=>true,
   "attrib="=>true,
   "self.method3"=>true,
   "method1="=>true,
   "method1?"=>true,
   "method1"=>true,
   "attrib"=>true,
   "method1!"=>true}}> expected but was
<{"Something"=>
  {"equal?"=>true,
   "attrib="=>true,
   "self.[]"=>true,
   "self.method3"=>true,
   "method1="=>true,
   "method1?"=>true,
   "method1"=>true,
   "attrib"=>true,
   "method1!"=>true}}>.

33 tests, 128 assertions, 1 failures, 0 errors

So, this is just a small example. When we were working on ParseTree we'd have individual test failures that were probably 50-100 lines long, with a 1 to 2 line change somewhere in the middle. So what do you do about this??? Well, it'd be nice to just see the differences between the expected an actual result. How? You use unit_diff of course!

% ruby  ./TestZenTest.rb | unit_diff
Requiring ZenTest
Loaded suite ./TestZenTest
Started
.................F...............
Finished in 0.123412 seconds.

  1) Failure:
test_klasses_equals(TestZenTest) [./TestZenTest.rb:468]:
3a4
>    "self.[]"=>true,
33 tests, 128 assertions, 1 failures, 0 errors

This one tool knocked HOURS off our debugging time. Try it now by downloading ZenTest.

If you'd like to see ZenTest in action, check out Pat Eyler's excellent articles How to Use ZenTest with Ruby and Test-First Ruby Programming.

Read: ZenTest and unit_diff

Topic: Paul Graham talk Previous Topic   Next Topic Topic: Agile Web Development with Rails

Sponsored Links



Google
  Web Artima.com   

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