Restart application between scenarios

1,384 views
Skip to first unread message

dan.z...@fortech.ro

unread,
Apr 9, 2013, 4:39:09 AM4/9/13
to calabash...@googlegroups.com
I know that calabash is configured by default to restart the application between two scenarios. Can it be configured not to do so? I'd like to have the tests run continuously, with no restarts between scenarios (only application reinstall between features) for better performance.

Thank you,
Dan

Alex

unread,
Apr 15, 2013, 9:10:23 AM4/15/13
to calabash...@googlegroups.com
Hi,

I am also looking for a solution to this problem. I tried to change "scenario" to the "future" in app_life_cycle_hooks.rb:

Before do |feature|
  start_test_server_in_background
end

but it does not change anything. Can anyone help?



вторник, 9 апреля 2013 г., 11:39:09 UTC+3 пользователь dan.z...@fortech.ro написал:

dan.z...@fortech.ro

unread,
Apr 15, 2013, 10:54:08 AM4/15/13
to calabash...@googlegroups.com
Edit the app_life_cycle_hooks.rb to look like this:

require 'calabash-android/management/adb'
require 'calabash-android/operations'

Before ("@restart") do |scenario|
start_test_server_in_background
end

After do |scenario|
  if scenario.failed?
    screenshot_embed
  end
  #shutdown_test_server
end

and use @restart before any scenario you want to restart the app :)
This fixed the problem for me.

Dan

Alex

unread,
Apr 16, 2013, 8:06:16 AM4/16/13
to calabash...@googlegroups.com
Thanks! It works.

понедельник, 15 апреля 2013 г., 17:54:08 UTC+3 пользователь dan.z...@fortech.ro написал:

Mario

unread,
May 28, 2014, 4:19:30 AM5/28/14
to calabash...@googlegroups.com
Hi,
Unfortunately Dan's solution doesn't work for me. When I change the app_life_cycle_hooks.rb as described above, I keep getting this error:
      HTTPClient::KeepAliveDisconnected (HTTPClient::KeepAliveDisconnected)
      features\myFeature.feature:5:in `Then I should see "App Navigation"'
Without the change it works fine but with the unwanted restarting. I also tried adding  After ("@restart") do |scenario|  but I only got the same error.

app_life_cycle_hooks.rb:

require 'calabash-android/management/adb'
require 'calabash-android/operations'

Before ("@restart") do |scenario|
  start_test_server_in_background
end

After do |scenario|
#After ("@restart") do |scenario|

  if scenario.failed?
    screenshot_embed
  end
  #shutdown_test_server
end


myFeature.feature:

Feature: Home screen and basic navigation

  Scenario: I can start my app
    Given my app is running
    Then I should see "App Navigation"
    And I should see "Simple Up Navigation"
    And I should see "Peer Activities"
    And I should see "View from other task"
   
  @restart
  Scenario: Go to "Simple Up Navigation" and back
    Given I am on the Home Screen
    Then I should see "App Navigation"
    ...
    ...
    ...


ruby: 1.9.3.
calabash: 0.4.21
cucumber: 1.3.15

Help is much appreciated.

Thanks,
Mario
Reply all
Reply to author
Forward
0 new messages