testunit: run single test

R

ruud grosmann

hello,

I'd like to be able to run one or two testroutines from a
Test::Unit::TestCase-object. Is that possible?

For example:

in test.rb:
====================
class TC_fe < Test::Unit::TestCase

def test_plus
assert_equal( 1+5, 6)
end

def test_minus
assert_equal( 1-5, 6)
end
end

==============
in do_it:
=================
#!/usr/bin/ruby1.8

require 'test'

===================

Now all testroutines from TC_fe are run. Is it possible only to run
test_minus? Or the routines with the names I collect via command line
arguments?

thanks in advance!

Ruud
 
R

ruud grosmann

no. no succes.

The point is that my do_it script in the mail is simplified a bit. It
is more like
==================
#!/usr/bin/ruby1.8

require 'getoptlong'
require 'test'

opts = GetoptLong.new(
#[ "--name", "-n", GetoptLong::REQUIRED_ARGUMENT ],
[ "-h", GetoptLong::NO_ARGUMENT ],
[ "-d", GetoptLong::NO_ARGUMENT ],
[ "-v", GetoptLong::NO_ARGUMENT ]
)
=====================

It either runs all tests (when I define the -n option which is
commented out above), or it complains that -n is an invalid option.
I am afraid that I have to code some things the Test-objects do
magically when nothing is specified.

But I have no single clue as to what it should be.

Any ideas?

tia, Ruud
 
J

Jano Svitok

no. no succes.

The point is that my do_it script in the mail is simplified a bit. It
is more like
==================
#!/usr/bin/ruby1.8

require 'getoptlong'
require 'test'

opts = GetoptLong.new(
#[ "--name", "-n", GetoptLong::REQUIRED_ARGUMENT ],
[ "-h", GetoptLong::NO_ARGUMENT ],
[ "-d", GetoptLong::NO_ARGUMENT ],
[ "-v", GetoptLong::NO_ARGUMENT ]
)
=====================

It either runs all tests (when I define the -n option which is
commented out above), or it complains that -n is an invalid option.
I am afraid that I have to code some things the Test-objects do
magically when nothing is specified.

But I have no single clue as to what it should be.

Any ideas?

tia, Ruud

Lookup test\unit\autorunner.rb and see how it does its stuff.
Copy&paste the part that starts only single thread.
Or delegate to its command line parser.

Jano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top