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?
Thanks,
Joe
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?
Thanks,
Joe
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
Joe Van Dyk wrote:
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?Thanks,
Joe
Just FYI:
RDT (the Ruby plugin for Eclipse) comes with a graphical test runner.
Regards,
Dan
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 }
Not sure if that would have any effect on what I'm trying to do or not.
On 6/29/05, gabriele renzi <surrender_it@remove-yahoo.it> 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 --gtkHTH
Quoting Joe Van Dyk <joevandyk@gmail.com>:
> 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
>
> HTHThanks, 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
On 6/29/05, gabriele renzi <surrender_it@remove-yahoo.it> wrote:
--
R. Mark Volkmann
Partner, Object Computing, Inc.
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.
On 6/29/05, R. Mark Volkmann <mark@ociweb.com> wrote:
Quoting Joe Van Dyk <joevandyk@gmail.com>:
> On 6/29/05, gabriele renzi <surrender_it@remove-yahoo.it> 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
endDir.foreach('../test') do |filename|
next if not filename =~ /(\S*Test).rb$/
require "../test/#{filename}"
klass = Object.const_get($1)
$runner.run(klass)
end
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
endDir.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:
On Jun 29, 2005, at 5:33 PM, R. Mark Volkmann wrote:
% ./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 - Seattle.rb | Home
http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c
Quoting Joe Van Dyk <joevandyk@gmail.com>:
On 6/29/05, R. Mark Volkmann <mark@ociweb.com> wrote:
> Quoting Joe Van Dyk <joevandyk@gmail.com>:
>
> > On 6/29/05, gabriele renzi <surrender_it@remove-yahoo.it> 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)
> endIt'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
endIt'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.
I have a feeling the only reason it is so simple for you it that it uses
Test::Unit::UI::Console::TestRunner by default. I think in order to run test
in graphical mode you're going to have to do something like I did to
specifically tell it to use Test::Unit::UI::Tk::TestRunner or one of the other
GUI TestRunners. Of course I'd love it if someone could show us a simpler way
than what I have done.
--
R. Mark Volkmann
Partner, Object Computing, Inc.
Quoting Joe Van Dyk <joevandyk@gmail.com>:
Currently, the file that runs all the unit tests looks something like
(from memory)Dir["tests/*.rb].each { |file| require file }
That one line is all that's in unit_tests.rb, which I run with 'ruby
unit_tests.rb'.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.
Just run your file with
testrb -rt unit_tests.rb
I'm doing more or less the same and it works for me.
Regards,
Pit
Quoting Pit Capitain <pit@capitain.de>:
> Quoting Joe Van Dyk <joevandyk@gmail.com>:
>>>>
>>>>Currently, the file that runs all the unit tests looks something like
>>>>(from memory)
>>>>
>>>>Dir["tests/*.rb].each { |file| require file }
>>
>>That one line is all that's in unit_tests.rb, which I run with 'ruby
>>unit_tests.rb'.
>>
>>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.Just run your file with
testrb -rt unit_tests.rb
I'm doing more or less the same and it works for me.
Wow! I wasn't aware of testrb. So there's no need to create a Ruby source file
that pulls all the test source files into a single file. You can just write
separate unit test files and execute them all with
testrb [-rtk] *.rb
If your unit tests are in a test directory that is a sibling directory of a lib
directory where the source files being tested are stored then you may want to
run the tests from the lib directory like this.
testrb [-rtk] ../test/*.rb
This allows the unit tests to require the source files they test without
specifying the path to them.
--
R. Mark Volkmann
Partner, Object Computing, Inc.