我的calabash android测试项目具有以下结构:
-- 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.rb ruby文件。
在 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)>'
...
因此,这是一个加载错误,看起来calabash-android无法加载在 thirdPartLib.rb 中声明的文件jmespath (LoadError)
。我怎样才能摆脱这个错误?
答案 0 :(得分:0)
您需要安装jmespath gem才能使用它。要安装它,您需要将它添加到您的gemfile。您可以按如下方式指定gem的本地副本
gem "foo", :path => "/path/to/foo"
取自此问题/答案的示例 - How can I specify a local gem in my Gemfile?