【发布时间】:2017-10-05 09:16:37
【问题描述】:
当我运行测试时,我在控制台中写入以下错误:
undefined method `split' for nil:NilClass (NoMethodError)
/Users/denis/.rvm/gems/ruby-2.1.1/gems/run_loop 1.2.6/lib/run_loop/sim_control.rb:866:in `block in sim_details'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/run_loop-1.2.6/lib/run_loop/sim_control.rb:863:in `each'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/run_loop-1.2.6/lib/run_loop/sim_control.rb:863:in `sim_details'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/run_loop-1.2.6/lib/run_loop/sim_control.rb:290:in `enable_accessibility_on_sims'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/run_loop-1.2.6/lib/run_loop/core.rb:214:in `run_with_options'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/run_loop-1.2.6/lib/run_loop/core.rb:792:in `run'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:755:in `block in new_run_loop'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:753:in `times'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:753:in `new_run_loop'
/Users/denis/.rvm/gems/ruby-2.1.1/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:624:in `relaunch'
/Users/denis/Documents/calabash-test-ios/x-platform-example/features/ios/support/01_launch.rb:27:in `Before'
测试本身是来自这里的example。以下是其中一个错误的代码:
def sim_details(primary_key)
unless xcode_version_gte_6?
raise RuntimeError, 'this method is only available on Xcode >= 6'
end
allowed = [:udid, :launch_name]
unless allowed.include? primary_key
raise ArgumentError, "expected '#{primary_key}' to be one of '#{allowed}'"
end
hash = {}
xctools.instruments(:sims).each do |elm|
launch_name = elm[/\A.+\((\d\.\d(\.\d)? Simulator\))/, 0]
udid = elm[XCODE_6_SIM_UDID_REGEX,0]
sdk_version = elm[/(\d\.\d(\.\d)? Simulator)/, 0].split(' ').first
value =
{
:launch_name => launch_name,
:udid => udid,
:sdk_version => RunLoop::Version.new(sdk_version)
}
if primary_key == :udid
key = udid
else
key = launch_name
end
hash[key] = value
end
hash
end
运行这个命令:bundle exec cucumber -p ios DEVICE_TARGET="6D45E1...6513"
有人能遇到吗?
【问题讨论】:
-
您能否在导致上述错误的行周围包含代码?
-
@ChuckvanderLinden 代码已添加
标签: ios ruby automated-tests cucumber