Search code examples
androidautomated-testsandroid-testingcalabashcalabash-android

Calabash - do not reinstall app on startup


My app on the first run the user has to authenticate.

I've a feature with different tagged scenarios. Now I need to run just a few scenarios but every time I run the following command

calabash-android run /path/to/apk features/my.feature --tags @Alert

My app is reinstalled which causes the tests to fail on my @Alert scenario. How can I tell calabash to not reinstall the app?

From googling around I found this which says:

Go to app_installation_hooks.rb file under support folder and comment out following 3 lines:

uninstall_apps
install_app(......)
install_app(......)

but I'm looking for a command or more elegant way to do what I want.


Solution

  • I think you need to update your app_installation_hooks and add a tagged Before hook.

    The Calabash iOS Smoke Test 01_launch.rb (yes, it is an iOS example, but the principles are the same) has examples of what I mean.

    Before('@reset_app_btw_scenarios') do
      if xamarin_test_cloud?
        ENV['RESET_BETWEEN_SCENARIOS'] = '1'
      elsif LaunchControl.target_is_simulator?
        target = LaunchControl.target
        simulator = RunLoop::Device.device_with_identifier(target)
        app = RunLoop::App.new(ENV['APP'])
        core_sim = RunLoop::CoreSimulator.new(simulator, app)
        core_sim.reset_app_sandbox
      else
        LaunchControl.install_on_physical_device
      end
    end