From: Ryan Davis Date: 2005-06-30T17:07:34+09:00 Subject: Re: running unit tests in graphical mode On Jun 29, 2005, at 5:33 PM, R. Mark Volkmann wrote: > Can it really be that simple? I thought you'd have to do something > like this. > > # This runs a suite of unit tests. > # Copy it to some directory in $PATH such as $RUBY_HOME/bin. > # Run it from your project lib directory where the unit test files > # are in a sibling directory named 'test'. > # Usage: ruby suite.rb [gui] > > if ARGV[0] == 'gui' > # Note: The one-click installer doesn't install Fox, GTK or GTK2. > require 'test/unit/ui/tk/testrunner' > $runner = Test::Unit::UI::Tk::TestRunner > else > require 'test/unit/ui/console/testrunner' > $runner = Test::Unit::UI::Console::TestRunner > end > > Dir.foreach('../test') do |filename| > next if not filename =~ /(\S*Test).rb$/ > require "../test/#{filename}" > klass = Object.const_get($1) > $runner.run(klass) > end You shouldn't need that if your test file requires 'test/unit'. It pretty much does all the stuff you are doing above for you. Then just run one of your test scripts with --help: > % ./test_inline.rb --help > Test::Unit automatic runner. > Usage: ./test_inline.rb [options] [-- untouched arguments] > > -r, --runner=RUNNER Use the given RUNNER. > (c[onsole], f[ox], g[tk], g[tk] > 2, t[k]) > -n, --name=NAME Runs tests matching NAME. > (patterns may be used). > -t, --testcase=TESTCASE Runs tests in TestCases > matching TESTCASE. > (patterns may be used). > -v, --verbose=[LEVEL] Set the output level (default > is verbose). > (s[ilent], p[rogress], n > [ormal], v[erbose]) > -- Stop processing options so > that the > remaining options will be > passed to the > test. > -h, --help Display this help. -- ryand-ruby@zenspider.com - Seattle.rb - http://www.zenspider.com/ seattle.rb http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c