From: Eric Hodel Date: 2006-03-24T10:49:42+09:00 Subject: Re: using unit test On Mar 23, 2006, at 5:38 PM, Joe Van Dyk wrote: > On 3/23/06, rtilley wrote: >> What is the most prevalent way of using unit testing in Ruby? Do I >> require 'test/unit' and add test methods to production scripts and >> then >> comment the testing portions out when not testing? Or, should I >> develop >> a 'testing' version of the scripts identical to the production >> versions? >> >> Thanks for any advice. I've got the concept down... just thinking >> about >> implementation and actively using tests. > > I generally put my tests in a separate tests directory from my code. > Then I have a 'run_tests.rb' file that runs all the tests. Here's the > entirety of run_tests.rb: > > Dir["tests/*"].each { |f| require f } > > Or, you could somehow use Rake to run the tests, like Rails does. Even easier: $ ls test/ $ ls test test_something.rb $ testrb test Loaded suite test Started . Finished in 0.012917 seconds. 1 tests, 1 assertions, 0 failures, 0 errors -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com