From: Sean O'Dell Date: 2004-07-07T06:33:40+09:00 Subject: Unit Testing Without Frameworks On Tuesday 06 July 2004 13:55, Lothar Scholz wrote: > > And to be honest i stopped unit tests, because the current libraries > GUI, networking, filesystems do not support them well enough. Hope > that this will improve in the future. I felt the same way. I got back into unit testing in a way I don't think most people would understand. I dropped frameworks altogether. I started just running anything found in a "tests" sub-directory of whatever project I was working on. Actually, I do have a framework of a sort: a single ruby file I use to launch tests that match a given name pattern. Here's the entire "framework": #!/usr/bin/ruby pattern = nil pattern = Regexp.new(ARGV.shift) if (ARGV.length > 0) Dir["tests/*"].each do | filename | next if (filename =~ /^\./) test = filename.clone test.slice!(/^.+\//) test.slice!(/\.rb$/) next if (not test =~ /^test_/) test.slice!(/^test_/) next if (pattern and not test =~ Regexp.new("^#{pattern}$")) print("---------- #{test}' ----------\n") system(filename) end print("---------- DONE ----------\n") Generally, in my tests, I just do whatever and let exceptions happen where they happen, and every test usually ends with a statement like: p a == expected_value So my entire "report" consists of a series of true or falses. When a false occurs, I just track it down and fix whatever caused the bug. Perhaps it's just my need for simplicity that makes this work better for me than a framework. Or perhaps current frameworks don't have the ability to really anticipate what everyone needs or wants. Whatever the reason, I am really into unit testing now. Sean O'Dell