黄瓜找不到模拟器

时间:2017-03-15 16:01:47

标签: ios ruby cucumber calabash calabash-ios

我们正在编写一些使用Cucumber和Calabash进行测试的自动化测试。我使用Calabash用于x平台,因为应用程序是用react-native编写的。我需要针对Android和iOS进行相同的测试。对于Android一切都很好,但在iOS上找到一个模拟器有问题。 我的实现与https://github.com/calabash/x-platform-example类似,但更简单。

我使用与x-platform-example相同的run.rb

#!/usr/bin/env ruby
target = ARGV.shift

unless system("bundle version")
  puts "Can't find bundler. Check your ruby environment."
  puts "If your using ~/.calabash then run:"
  puts <<EOF

export GEM_HOME=~/.calabash
export GEM_PATH=~/.calabash
export PATH="$PATH:$HOME/.calabash/bin"
EOF
  exit(false)
end

if target == 'android'
  exec("export APP=../android/app/build/outputs/apk/app-debug.apk && bundle exec calabash-android run $APP -p android #{ARGV.join(' ')}")
elsif target == 'ios'
  exec("export APP=/Users/salek/Library/Developer/Xcode/DerivedData/myapp-bgunorhzqeoiyxaxiijyjvgvdavf/Build/Products/Debug-iphonesimulator/myapp.app && export APP_BUNDLE_PATH=$APP && bundle exec cucumber -p ios #{ARGV.join(' ')}")
else
  puts "Invalid target #{target}"
end

这是我的cucumber.yml配置:

# config/cucumber.yml
##YAML Template
---
android:
  PLATFORM=android
  -r features/support
  -r features/android
  -r features/step_definitions
  -r features/android/pages


ios:
  PLATFORM=ios

  APP_BUNDLE_PATH=/Users/salek/Library/Developer/Xcode/DerivedData/myapp-bgunorhzqeoiyxaxiijyjvgvdavf/Build/Products/Debug-iphonesimulator/myapp.app
  -r features/support
  -r features/ios/support
  -r features/ios/helpers
  -r features/step_definitions
  -r features/ios/pages

当我跑cucumber ./run ios时,我得到了:

Bundler version 1.14.6
Using the ios profile...
Feature: Initial experience
  This is basic description about this feature...

  @info @reinstall
  Scenario: I can describe everything what i want.                   # features/HomeScreenTestScenario.feature:5
    This scenario is my first and i would like to test some buttons.
    I am going to use 'when' and 'then' block:
 Could not find a simulator that matches 'iPhone 5s (8.3 Simulator)' (RuntimeError)
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:289:in `reset_app_sandbox'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:200:in `reset_app_jail'
 /Users/salek/Documents/work/cngroup.dk/MRDM/HemoNed/hemonedskeleton/cucumber/features/ios/support/01_launch.rb:24:in `Before'
    Given I am on Home Screen                                        # features/step_definitions/home_screen.rb:2

Failing Scenarios:
cucumber -p ios features/HomeScreenTestScenario.feature:5 # Scenario: I can describe everything what i want.
This scenario is my first and i would like to test some buttons.
I am going to use 'when' and 'then' block:

1 scenario (1 failed)
1 step (1 skipped)
0m0.374s

我还没有定义模拟器Could not find a simulator that matches 'iPhone 5s (8.3 Simulator)' (RuntimeError) 我将此添加到我的cucumber.yml配置:

...
ios:
  PLATFORM=ios
  DEVICE_TARGET="063C3296-0770-47FB-8BC4-7074CDE59845"
...

现在日志已更改为:

bundler version 1.14.6
Using the ios profile...
Feature: Initial experience
  This is basic description about this feature...

  @info @reinstall
  Scenario: I can describe everything what i want.                   # features/HomeScreenTestScenario.feature:5
    This scenario is my first and i would like to test some buttons.
    I am going to use 'when' and 'then' block:

WARN: calling 'reset_app_sandbox' when targeting a device.
 undefined method `split' for nil:NilClass (NoMethodError)
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/run_loop-1.2.9/lib/run_loop/sim_control.rb:867:in `block in sim_details'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/run_loop-1.2.9/lib/run_loop/sim_control.rb:864:in `each'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/run_loop-1.2.9/lib/run_loop/sim_control.rb:864:in `sim_details'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/run_loop-1.2.9/lib/run_loop/sim_control.rb:290:in `enable_accessibility_on_sims'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/run_loop-1.2.9/lib/run_loop/core.rb:201:in `run_with_options'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/run_loop-1.2.9/lib/run_loop.rb:77:in `run'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:755:in `block in new_run_loop'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:753:in `times'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:753:in `new_run_loop'
 /Users/salek/.rvm/gems/ruby-2.2.4/gems/calabash-cucumber-0.12.2/lib/calabash-cucumber/launcher.rb:624:in `relaunch'
 /Users/salek/Documents/work/myapp/cucumber/features/ios/support/01_launch.rb:27:in `Before'
    Given I am on Home Screen                                        # features/step_definitions/home_screen.rb:2

Failing Scenarios:
cucumber -p ios features/HomeScreenTestScenario.feature:5 # Scenario: I can describe everything what i want.
This scenario is my first and I would like to test some buttons.
I am going to use 'when' and 'then' block:

1 scenario (1 failed)
1 step (1 skipped)
0m1.899s

应用程序仍然无法在模拟器中运行 但我认为这是问题所在:

WARN: calling 'reset_app_sandbox' when targeting a device.
 undefined method `split' for nil:NilClass (NoMethodError)

但我不会在代码中使用split

1 个答案:

答案 0 :(得分:0)

我不知道在cucumber.yml文件中使用换行符。 我看起来更像这个

  

ios:APP_BUNDLE_PATH = iphone / build / Applications / myapp.app PLATFORM = ios   DEVICE_TARGET ='iPhone 6(9.1)'RESET_BETWEEN_SCENARIOS = 1 -r   功能/支持-r功能/ ios / support -r功能/ ios / helpers -r   features / step_definitions -r features / ios / pages features / login.feature

然后在运行时添加有关要使用的配置文件的信息

  

-p ios

关于iOS中的模拟器,您可以使用模拟器的名称而不是ID。但是你使用的那个必须安装在你的原因设置上。

我有一些不同的配置文件用于测试不同的设备,我的设备列表看起来像这些

  

DEVICE_TARGET ='iPhone 6(9.1)'

     

DEVICE_TARGET ='iPhone 5(9.1)'

对我来说,你得到的第一个错误看起来就像你没有安装那个模拟器一样。

相关问题