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