【发布时间】:2016-09-05 17:30:43
【问题描述】:
我的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)。我怎样才能摆脱这个错误?
【问题讨论】:
-
jmespath gem 安装了吗?
-
没有。它不是。但是我不能只安装 gem,因为我需要将我的葫芦测试项目上传到云端才能运行,我需要将所有 3rd 方库 ruby 文件放在我的测试项目的
support/目录下 -
你能把 jmespath 添加到你的 Gemfile 吗?
-
@DaveSchweisguth,我不确定,我可以试试,但我不知道如何将它添加到 Gemfile
-
你有 Gemfile 吗?如果是这样,您可以将其添加到您的问题中。我不知道你是否这样做,但如果你这样做了,这可能是解决问题的方法。
标签: android ruby cucumber calabash calabash-android