Search code examples
ioscucumbercalabashcalabash-ios

Calabash-cucumber simulator not running same version of app as the "-cal" scheme


I start out with the "-cal" scheme running just like the Calabash setup guide tells me to. Then I run cucumber for Calabash-iOS. The simulator seems to stop and restart before executing the tests in a different (possibly cached version) of my app and the target device has changed from an iPhone 6 to running the tests in an iPhone 5s.

How can I make cucumber execute the tests in the already running "-cal" scheme? Or (better yet) how can I make it relaunch using the "-cal" scheme? I can see cases where relaunching would be valuable.

Below is the only code executed before the scenarios run. I know it says .relaunch is in there, but if I take it out then the test fails on the first step.

Before do |scenario|
  @calabash_launcher = Calabash::Cucumber::Launcher.new
  unless @calabash_launcher.calabash_no_launch?
    @calabash_launcher.relaunch
    @calabash_launcher.calabash_notify(self)
  end
end

Solution

  • So there are few questions there.

    1. How can I make cucumber execute the tests in the already running "-cal" scheme? Answer: When you build the cal target you define what target to build for and when you execute the tests you define what target to execute on. Build: -sdk iphonesimulator9.0 Execute: DEVICE_TARGET='iPhone 6 Plus (9.0)'

    2. The simulator seems to stop and restart before executing the tests in a different (possibly cached version) of my app and the target device has changed from an iPhone 6 to running the tests in an iPhone 5s. Answer: Also related partly to question 1 (defining target to control what setup you test on). Besides that the app will relaunch between scenarios otherwise each scenario would be dependent on what ever else had been executed before it. The one thing you can toggle is if the app should be reinstalled between scenarios. This is helpful if you have some functionality that only shows/executes on first install/launch. To add support for reinstall you can add something like this to the launch.rb file in "Before do |scenario|"

      if scenario_tags.include?('@reinstall') @calabash_launcher.reset_app_sandbox end