command line arguments in unit/test

R

Rick Tan

How do I get to the command line arguments in test/unit. In the
following class definition, ARGV is showing empty

class RunitTest < Test::Unit::TestCase

def setup
 
A

Alex Young

Does this help?


$ cat /tmp/trial.rb

require 'test/unit'

$my_argv = ARGV.dup

class MyTest < Test::Unit::TestCase
def setup
p $my_argv
end

def test_dummy; end
end

$ ruby /tmp/trial.rb foo bar qux
Loaded suite /tmp/trial
Started
["foo", "bar", "qux"]
 
R

Rick Tan

Yes, it does.

Thanks a lot

-Rick

Alex Young wrote in post #989065:
Does this help?


$ cat /tmp/trial.rb

require 'test/unit'

$my_argv = ARGV.dup

class MyTest < Test::Unit::TestCase
def setup
p $my_argv
end

def test_dummy; end
end

$ ruby /tmp/trial.rb foo bar qux
Loaded suite /tmp/trial
Started
["foo", "bar", "qux"]
.
Finished in 0.00097 seconds.

1 tests, 0 assertions, 0 failures, 0 errors
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top