From: Nathaniel Talbott Date: 2005-05-07T01:09:22+09:00 Subject: Re: unit test Brian Buckley wrote: > I'm not sufficiently familiar with ruby -- might there be custom settings > that I am setting on my box which aren't on yours? (ruby's equivalent to > java's classpath? loadpath?) > > And one more piece of diagnosis info: the code below shows the four methods > that are being added (It still doesn't explain why this only happens to me > when using the name "test_bad_data" or why our method counts are off - 83 vs > 82) > > Any suggestions? > ["pretty_print_cycle", > "pretty_print_inspect", > "pretty_print", > "pretty_print_instance_variables"] OK, I know what's going on now. 'pp' (PrettyPrint) adds those four methods to Object (or Kernel, I can't remember) when it's required, and test/unit requires pp when it builds the message for the failed assertion. The reason I wasn't seeing my methods go up is because when I wrote my little test program, I was requiring pp at the top, thus the methods were already there. The funny thing is I deleted that line before posting, thinking, "Awwww, it won't matter". You have three options: explicitly require pp, disable the use of pp by test/unit (Test::Unit::Assertions.use_pp = false), or change your code so that it doesn't care. I'd favor the last option, since Ruby's dynamic nature makes a method count extremely brittle. Perhaps you could explicitly check for methods you expect to be there, or better yet, whether the object you're testing #responds_to? the methods of interest? HTH, -- Nathaniel <:((><