Cucumber cannot find simulator

454 Views Asked by At

We are writing some automated tests using Cucumber and Calabash for tests. I use Calabash for x-platform because the application is written in react-native. And I need the same tests for Android and iOS. For Android everything is fine but on iOS have a problem finding a simulator. My implementation is similar as https://github.com/calabash/x-platform-example but simpler.

I used the same run.rb as x-platform-example:

#!/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

And this is my cucumber.yml config:

# 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

When I ran cucumber ./run ios I got:

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

I have not defined simulator Could not find a simulator that matches 'iPhone 5s (8.3 Simulator)' (RuntimeError) I added this to my cucumber.yml config:

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

Now the log changed to:

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

The application still can not run in the simulator but I think this is the problem:

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

But I don't use split in the code.

1

There are 1 best solutions below

0
Lasse On

I don't know about using line breaks in the cucumber.yml file. Mine looks more like this

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

And then when running it you add information about what profile to use

-p ios

About the simulator in iOS you can use the name the simulator has instead of an id. But the one you use has to be installed on your setup of cause.

I have a few different profiles for testing different devices and the list of devices for me looks like these

DEVICE_TARGET='iPhone 6 (9.1)'

DEVICE_TARGET='iPhone 5 (9.1)'

And to me the first error you got looks like it's just related to you not having that simulator installed.