From: Ryan Davis Date: 2011-03-27T05:12:51+09:00 Subject: Re: Clearer errors in 1.9's minitest On Mar 25, 2011, at 21:13 , spiralofhope wrote: > Hello! > > I've been getting back into Ruby, and one of the major changes I've > made is to switch to 1.9 and to strictly use tests. I'm using the > minitest[1] in 1.9 (via rvm[2]) > > It's nice, and I'm pleased at what I've been able to accomplish with > its help. > > However, it's been long enough that one issue has pissed me off > to no end and I need some advice on it. I'm not sure how to describe > what I'm looking for concisely enough to search for it effectively, so > I thought I'd sign up and ask. > > When an error is caught, its output is not as helpful as I wish it to > be. > > Example script: > > ---------- > require 'minitest/autorun' > > class Test_Markup < MiniTest::Unit::TestCase > > def test() > assert_equal( > ( 'asdfghjkl asdfghjkl asdfghjkl asdfghjkl asdfghjkl ' ), > ( 'qwertyuiop qwertyuiop qwertyuiop qwertyuiop qwertyuiop ' ), > ) > end > > end You don't actually write your code that way, do you? > Example output: [...] > > How challenging would this be to implement? If there were some way for > me to "get at" that text, I could use existing and very mature external > tools to do exactly what I want. e.g. if I were given one big array > with sub-arrays, within which is all the error information.. then I > could do some real magic. > > I'd really rather not use an alternative to minitest, mostly because > the syntax used in them makes me want to scoop my brain out with a > teaspoon. > > Point me to websites, documentation or source code. Any and all help > is appreciated. You already have the source code. Have you read it? It is called minitest for a reason. Dig in. > % ./x.rb > Run options: --seed 34017 > > # Running tests: > > F > > Finished tests in 0.000610s, 1639.3443 tests/s, 1639.3443 assertions/s. > > 1) Failure: > test_example(TestMarkup) [./x.rb:8]: > Expected "asdfghjkl asdfghjkl asdfghjkl asdfghjkl asdfghjkl ", not "qwertyuiop qwertyuiop qwertyuiop qwertyuiop qwertyuiop ". > > 1 tests, 1 assertions, 1 failures, 0 errors, 0 skips versus: > % sudo gem install ZenTest > % ./x.rb | unit_diff -u > Run options: --seed 4937 > # Running tests: > > F > > Finished tests in 0.000641s, 1560.0624 tests/s, 1560.0624 assertions/s. > > Run options: --seed 4937 > > 1) Failure: > test_example(TestMarkup) [./x.rb:8]: > --- /var/folders/x-/x-z1ojKcE+CpI1+qvSPWTk+++TU/-Tmp-/expect20110326-21801-yrc96l-0 2011-03-26 13:11:21.000000000 -0700 > +++ /var/folders/x-/x-z1ojKcE+CpI1+qvSPWTk+++TU/-Tmp-/butwas20110326-21801-zn2uft-0 2011-03-26 13:11:21.000000000 -0700 > @@ -1 +1 @@ > -"asdfghjkl asdfghjkl asdfghjkl asdfghjkl asdfghjkl " > +"qwertyuiop qwertyuiop qwertyuiop qwertyuiop qwertyuiop " > > 1 tests, 1 assertions, 1 failures, 0 errors, 0 skips