calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

Launcher.relaunch always reinstall DeviceAgent without checking of app existence #1280

Closed joyzoursky closed 7 years ago

joyzoursky commented 7 years ago

It is expected that when running scenarios with cucumber, Calabash::Cucumber::Launcher.relaunch should be able to reuse the already attached automator, and launch the target app directly to start another scenario (assuming DeviceAgent is already installed and attached when running the first scenario).

However, in the debug log, it is shown that DeviceAgent takes more than 30s to be reinstalled before every scenario, even though it is already existing on the device. As I am running a test with around 50 scenarios, this problem greatly affects the performance of the whole test.

The followings are my scripts in 01_launch.rb:

Before do |scenario|
  @calabash_launcher = Calabash::Cucumber::Launcher.new
  @calabash_launcher.relaunch
  @calabash_launcher.calabash_notify(self)
end
After do |scenario|
  unless @calabash_launcher.quit_app_after_scenario?
    calabash_exit
    if @calabash_launcher.active?
      @calabash_launcher.stop
    end
  end
end

Debug log when running with cucumber:

SHELL: /path/to/run_loop-2.3.0/lib/run_loop/device_agent/bin/iOSDeviceManager install --device-id <my-device-udid> -a /path/to/run_loop-2.3.0/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app
DEBUG: Took 37.440535 seconds to install DeviceAgent
SHELL: /path/to/run_loop-2.3.0/lib/run_loop/device_agent/bin/iOSDeviceManager start_test --device-id <my-device-udid> >& /path/to/.run-loop/xcuitest/ios-device-manager.log
jmoody commented 7 years ago

Please see the updated launch hooks.

It is expected that when running scenarios with cucumber, Calabash::Cucumber::Launcher.relaunch should be able to reuse the already attached automator, and launch the target app directly to start another scenario (assuming DeviceAgent is already installed and attached when running the first scenario).

Yes, this is the expected behavior.

iOSDeviceManager install --device-id -a /path/to/run_loop-2.3.0/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app

The application is probably not being re-installed. The install command does this:

  1. Check to see if the application is installed.
  2. If installed, do a comparison of the version numbers of the installed version and the new application and if necessary, update the installed application.

Step 1. can be incredibly slow if there are more than a few applications installed on the phone or your code signing environment is non-trivial (many profiles and certs) - ~30 seconds is fairly common. The next release of the DeviceAgent should have an improvement.

joyzoursky commented 7 years ago

I see, thanks for reply. We may move the launch steps to global env.rb to skip this part and speed up the whole test. Looking forward to the improvement, thanks!