command line arguments in unit/test

  • Follow


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
   .
   <-- I like to parse the command line arguments here or somewhere
before
   the code in test_runit are executed.
   .
  end

  def test_runit

  end
end


Thanks in advance

-- 
Posted via http://www.ruby-forum.com/.

0
Reply bellcolt (4) 3/24/2011 7:21:15 PM

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

--
Alex

-- 
Posted via http://www.ruby-forum.com/.

0
Reply Alex 3/24/2011 7:37:35 PM


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
>
> --
> Alex

-- 
Posted via http://www.ruby-forum.com/.

0
Reply Rick 3/25/2011 4:15:23 PM

2 Replies
563 Views

(page loaded in 0.005 seconds)

Similiar Articles:













7/20/2012 4:40:07 AM


Reply: