So there I was building a wee test with testunit-0.1.4 and ruby 1.6.7 when
the test suite ran but ran no test cases.
Weird.
After much fiddling I worked out why.
I was doing an all-in-one-file program and test. However I wanted the
program to print out a help if no args were found and run the test if the
command line arg was “test”.
Something deep and undocumented in TestRunner looks at ARGV and does
something with them and then doesn’t run my test cases.
Sad.
Here is a minimal bit of code to generate the glitch…
===the file boo====
require ‘test/unit’
class TC_Normalize < Test::Unit::TestCase
def test_missingheader
puts “Huh?”
end
end
···
=================
ruby boo
ruby ./boo
Loaded suite ./boo
Started…
…Huh?
Finished in 0.026578 seconds.
1 runs, 0 assertions, 0 failures, 0 errors
So that worked OK.
Now add an argument…
ruby ./boo bah
Loaded suite ./boo
Started…
Finished in 0.018516 seconds.
0 runs, 0 assertions, 0 failures, 0 errors
Whoops, 0 runs.
Ooh, lets try a wild guess…
ruby ./boo test_missingheader
Loaded suite ./boo
Started…
.Huh?
Finished in 0.000962 seconds.
1 runs, 0 assertions, 0 failures, 0 errors
Yip, definitely an undocumented feature down there somewhere…
Yip, in unit.rb is a bunch of code that does something, err, interesting
with ARGV.
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : john.carter@tait.co.nz
New Zealand
Good Ideas:
Ruby - http://www.ruby-lang-org - The best of perl,python,scheme without the pain.
Valgrind - Valgrind Home - memory debugger for x86-GNU/Linux
Free your books - http://www.bookcrossing.com