[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

testunit: run single test

ruud grosmann

8/5/2008 7:41:00 AM

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

3 Answers

Farrel Lifson

8/5/2008 7:47:00 AM

0

This should work
ruby test.rb -n test_minus


Farrel
--
Aimred - Ruby Development and Consulting
http://www....

ruud grosmann

8/5/2008 8:49:00 AM

0

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

Jano Svitok

8/5/2008 9:55:00 AM

0

On Tue, Aug 5, 2008 at 10:48, ruud grosmann <r.grosmann@gmail.com> wrote:
> 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