From: Robert Citek Date: 2009-12-11T23:51:02+09:00 Subject: Re: Test::Unit - Ruby Unit Testing Framework Questions Hello Bill, On Thu, Oct 22, 2009 at 9:02 AM, Bill Mosteller wrote: > With Test::Unit:  I lose the ability to pick browser and have to do a > lot more typing to pick a test, and that typing has to be spot on.  I > can help the latter problem with some careful re-naming. > > I had thought to turn driver into a unit test by surrounding it with the > basic code, but I cannot figure out how to get to the ARGV array once I > do that, so I cannot read the command line. I am also trying to get more familiar with Test::Unit. In my case I have some scripts that operate on a sqlite3 database. Since a sqlite3 database is just a file with some arbitrary name, I needed to be able to pass in the name of the file to the testing script. The solution I used was this construct: require 'test/unit' require 'sqlite3' require 'lib/sample.rb' $dbfile = ARGV[0] || "sample.db" exit unless File.exist?($dbfile) class TestSample < Test::Unit::TestCase .... In this way I was able to test my sample.rb code using the foo.db like this: $ ./tests/test_sample.rb foo.db and if I wanted to test it with the bar.db, I could do this: $ ./tests/test_sample.rb bar.db And if I don't specify a file, it defaults to "sample.db". I don't know if that is the "right way" to do it, but it's working for me thus far. Let us know what you've tried and what works (and what doesn't) for you. Regards, - Robert