From: Joe Van Dyk Date: 2005-06-30T09:48:46+09:00 Subject: Re: running unit tests in graphical mode On 6/29/05, R. Mark Volkmann wrote: > Quoting Joe Van Dyk : > > > On 6/29/05, gabriele renzi wrote: > > > Joe Van Dyk ha scritto: > > > > Hi, > > > > > > > > If I have a bunch of unit tests that all require 'test/unit', what's > > > > the best way to run all those unit tests in a graphical test runner? > > > > > > I think if you do > > > ruby testfile.rb --help > > > you shopuld be able to see some gui options, i.e. --fox or --gtk > > > > > > HTH > > > > > > Thanks, I'll try that out. > > > > Currently, the file that runs all the unit tests looks something like > > (from memory) > > > > Dir["tests/*.rb].each { |file| require file } > > 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 It's that simple, at least for me. That one line is all that's in unit_tests.rb, which I run with 'ruby unit_tests.rb'. Then, in the tests directory are a bunch of files like require 'test/unit' require 'what_i_am_testing' class MyTestClass < Test::Unit::TestCase def test_blah # ... end end It's very nice not to have to do any other crufty setup-type things to run unit tests. And so my question was how can I easily modify my current way of unit tests to run tests in a graphical mode.