我的葫芦安卓测试项目有以下结构:
-- myApp.apk
-- features (directory)
|-- my-feature-1-file-name.feature
|-- step_definitions (directory)
| calabash_steps.rb
|-- support (directory)
| thirdPartyLib.rb
我的葫芦测试步骤需要使用第三方库thirdPartyLib.rb。正如你上面看到的,在features/
目录下,我有一个support/
目录,在那里,我有一个thirdPartyLib。 ruby file.
内的 thirdPartyLib。rb,第一行代码如下:
require 'jmespath'
...
当我去到我的项目根,并运行calabash-android run myApp.apk DEBUG=1
命令测试,我得到以下错误:
DEBUG: Setting Android SDK location to $ANDROID_HOME
DEBUG: Android SDK location set to '/Users/John/Library/Android/sdk'
DEBUG: Set aapt path to '/Users/John/Library/Android/sdk/build-tools/23.0.3/aapt'
DEBUG: Set zipalign path to '/Users/John/Library/Android/sdk/build-tools/23.0.3/zipalign'
DEBUG: Set adb path to '/Users/John/Library/Android/sdk/platform-tools/adb'
DEBUG: Set android jar path to '/Users/John/Library/Android/sdk/platforms/android-24/android.jar'
DEBUG: Setting Java SDK location to $JAVA_HOME
DEBUG: Java SDK location set to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home'
DEBUG: Found java on PATH
DEBUG: Set java path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java'
DEBUG: Found keytool on PATH
DEBUG: Set keytool path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/keytool'
DEBUG: Found jarsigner on PATH
DEBUG: Set jarsigner path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/jarsigner'
cannot load such file -- jmespath (LoadError)
/Users/John/.calabash/sandbox/Rubies/2.1.6-p336/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/John/.calabash/sandbox/Rubies/2.1.6-p336/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/John/my-calabash-test/features/support/thirdPartyLib.rb:1:in `<top (required)>'
...
所以,这是一个加载错误,它看起来像葫芦-android不能加载文件jmespath (LoadError)
声明在thirdPartLib。rb 。怎样才能消除这个错误呢?
您需要安装jmespath gem才能使用它。要安装它,你需要将它添加到你的gemfile中。你可以像下面这样指定gem的本地副本
gem "foo", :path => "/path/to/foo"
取自这个问题/答案的例子-我如何在我的Gemfile中指定一个本地gem ?