On Tue, Feb 25, 2003 at 01:16:58AM +0900, Paul Brannan wrote: > I have a test that looks like this: > > require 'test/unit' > > class My_Test < Test::Unit::TestCase > def test_1 > assert_equal('10', '10') # okay > assert_equal(10, '10') # failure > end > end ... > 1) Failure!!! > test_1(My_Test) [test2.rb:6]: > <10> expected but was > <10> > > 1 tests, 2 assertions, 1 failures, 0 errors > > It's not immediately obvious why <10> is not equal to <10>. > > 1) Is there anything I can do to get a more useful assertion failure > message? If this is a problem with just one test, you could always do something like: assert(a=='10', "<10><String> expected but was\n<#{a}><#{a.class}>") > 2) When I want to differentiate like this in my own code, I use #inspect > instead of #to_s. I'm not sure if that's appropriate here, since > #inspect works well for integers and strings and regexes, but might > not work well with user-defined types. Could Test::Unit use #inspect > instead of #to_s, and would there be any unwanted side-effects? I don't know either, but it seems that it would be a good idea for assert_equal to check for expected.to_s == actual.to_s, and if so, provide a more detailled error message [probably using 'inspect'] There are other cases where that would be useful - structs which are not equal, for example. Regards, Brian.