我需要让我的 webdriver 测试命中多个服务器。我的解决方案是传入命令行参数,但是在运行下面的代码时使用
ruby webdriver/e2e/*.rb -s=localhost
或者
ruby webdriver/e2e/*.rb --server=localhost
但我收到以下错误。我收到以下错误
C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:49:in `process_args': invalid argument: -s=localhost (OptionParser::InvalidArgument)
from C:/Ruby193/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
from C:/Ruby193/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:21:in `run'
from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'
测试.rb
require 'test/unit'
require 'optparse'
class SuperTestClass < Test::Unit::TestCase
def setup
@server = "https://localhost/"
optparse = OptionParser.new do|opts|
opts.on( '-s', '--server server', 'Server to run tests against' ) do|server|
@server = server
end
end
...
end
...
end
更新
我变了
opts.on( '-s', '--server server', 'Server to run tests against' ) do|server|
到
opts.on( '-serv', '--server server', 'Server to run tests against' ) do|server|
但它没有解决它