HowTo force calabash to reinstall/or not the application between scenarios/features?

6,504 views
Skip to first unread message

Marius Bob

unread,
Apr 4, 2013, 9:32:40 AM4/4/13
to calabash...@googlegroups.com

Hello,

 

            As I noticed, calabash-android restarts the application between scenarios and clears the data between features. I know there is the possibility to run a command and set the RESET_BETWEEN_SCERNARIOS variable to 1 or 0 but I want a little more J

            I took a look over https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/operations.rb file and noticed some install/reinstall methods.

            Questions:

-          Is there a way to force calabash for – example -  to reinstall the application after a certain scenario? – I have one feature file containing 10 scenarios. Let’s say I want calabash to do a reinstall after scenario no. 6 and NO other reset for the other scenarios. Is this possible to somehow call a method in order to perform the reinstallation?

-          I raise the same question regarding the features. I have 10 feature files and I DON’T want to reset the application only after feature no. 6.

Thanks,

Marius

 

 

 

Jonas Maturana Larsen

unread,
Apr 4, 2013, 10:07:44 AM4/4/13
to calabash...@googlegroups.com
I think you want to do it before a scenario and not after a scenario since it is a certain scenario that has special pre conditions.

You can add a tag e.g. @reinstall
In the hook you force a reinstall using this check:

if scenario.source_tags_names.include? "@reinstall"
reinstall_apps()
end
--
You received this message because you are subscribed to the Google Groups "calabash-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to calabash-andro...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Marius Bob

unread,
Apr 5, 2013, 8:13:05 AM4/5/13
to calabash...@googlegroups.com

Thanks!

That worked!

 

From: calabash...@googlegroups.com [mailto:calabash...@googlegroups.com] On Behalf Of Jonas Maturana Larsen
Sent: Thursday, April 04, 2013 17:08 PM
To: calabash...@googlegroups.com
Subject: Re: HowTo force calabash to reinstall/or not the application between scenarios/features?

 

I think you want to do it before a scenario and not after a scenario since it is a certain scenario that has special pre conditions.

 

You can add a tag e.g. @reinstall

In the hook you force a reinstall using this check:

 

if scenario.source_tags_names.include? "@reinstall"

                reinstall_apps()

end

 

On Thursday, April 4, 2013 at 15:32 , Marius Bob wrote:

Hello,

 

            As I noticed, calabash-android restarts the application between scenarios and clears the data between features. I know there is the possibility to run a command and set the RESET_BETWEEN_SCERNARIOS variable to 1 or 0 but I want a little more J

            I took a look over https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/operations.rb file and noticed some install/reinstall methods.

            Questions:

Is there a way to force calabash for – example -  to reinstall the application after a certain scenario? – I have one feature file containing 10 scenarios. Let’s say I want calabash to do a reinstall after scenario no. 6 and NO other reset for the other scenarios. Is this possible to somehow call a method in order to perform the reinstallation?

I raise the same question regarding the features. I have 10 feature files and I DON’T want to reset the application only after feature no. 6.

Thanks,

Marius

 

 

 

--
You received this message because you are subscribed to the Google Groups "calabash-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to calabash-andro...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Shailendra Singh

unread,
Apr 10, 2013, 6:31:53 AM4/10/13
to calabash...@googlegroups.com
In Scenario I add tag @reinstall

and in Hooks.rb i have written below code:
 require 'calabash-android/management/adb'
require 'calabash-android/operations'


Before do |scenario| 

if scenario.source_tags_names.include? "@reinstall"
reinstall_apps()
end

end


but On execution I am getting error  "undefined method `source_tags_names' for #<Cucumber::Ast::Scenario:0x2860800> (
NoMethodError)"

what to do?

Karl Krukow

unread,
Apr 10, 2013, 6:37:12 AM4/10/13
to calabash...@googlegroups.com
You probably just want

Before('@reinstall') do |scenario|

end

Shailendra Pratap

unread,
Apr 10, 2013, 7:07:15 AM4/10/13
to calabash...@googlegroups.com
It Worked.

Thanks


You received this message because you are subscribed to a topic in the Google Groups "calabash-android" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/calabash-android/Ql3iluRMijg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to calabash-andro...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.





--
shailendra pratap singh

Wayne Douglas

unread,
Jul 9, 2013, 5:36:05 AM7/9/13
to calabash...@googlegroups.com
mine seems to be re-installing by default between scenarios - this takes a while as it re-uploads it to the device.

How can I stop it from doing this and instead just re-start the app?

Senthazal Ravi

unread,
Aug 21, 2013, 12:51:59 AM8/21/13
to calabash...@googlegroups.com
I have a different problem. my app is 12 mb and everytime calabash is installing the app before performing the scenario. is there a way to stop this and force calabash not to reinstall the app before performing the scenario ? 

Ravi

Jerry Tom

unread,
Sep 1, 2014, 12:40:25 AM9/1/14
to calabash...@googlegroups.com
Hi,

I'm looking for a similar solution: I want the android app to reset data and not re-install after every Scenario. Is it configurable in the app_installation_hooks file?

Thanks,
Jerry

Preeti Jindal

unread,
Sep 2, 2014, 9:18:08 AM9/2/14
to calabash...@googlegroups.com
Hello Jerry,

Yes, you can force calabash not to install application everytime.
Go to app_installation_hooks.rb file under support folder and comment out following 3 lines:

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

Whenever you feel like installing application again remove the comments.

And one important thing, whenever you run calabash for the first time on any machine, make sure to install application through calabash only. And do not comment out the code as on installing application first time, installs instrumentation server on the device without which scenarios won't execute.

Nir Ortal

unread,
Mar 1, 2015, 4:14:47 AM3/1/15
to calabash...@googlegroups.com
Hi,

how do i do the opposite?
i have an app that needs registration for the first login.
the first feature is the first login and the second feature is workout with the existing user.
the second feature reinstall the app and brings me back to the first login page (registration).

is there an annotation or a command for not reinstall?

DZ

unread,
Mar 1, 2015, 7:53:59 AM3/1/15
to calabash...@googlegroups.com
Hi Nir,
as i see it you have two options.
one is merging the features to one feature.
in this case, first  scenario should be the login and since it is the first in the feature, app will re install prior to this scenario runnig.
second scenario should be the "workout with the existing user" and since it is second, app will not reinstall.

second option is inserting a special case inside the app_installation_hooks file that once the tag of the second feature is recognized, app should not reinstall

hope this helps...

Nir Ortal

unread,
Jul 11, 2016, 4:45:09 AM7/11/16
to calabash-android
Hi,

How do I tag them? - can you please write an example?
I tried that and get error.

DZ

unread,
Jul 11, 2016, 4:48:50 AM7/11/16
to calabash-android
what do you mean by "tag them"?

Bita Kazemi

unread,
Oct 25, 2016, 5:19:33 PM10/25/16
to calabash-android
Thanks Jonas,
I got the general idea from your reply. I also add what I did and maybe someone find it useful.
So under where your calabash folder is : calabash/features/support , you can find a support directory and there are four files residing there in general:
app_installation_hooks.rb    app_life_cycle_hooks.rb        hooks.rb
    env.rb
before doing anything, make sure you get a copy of app_installation_hooks.rb and then comment or omit the uninstall app line from it and save.
require 'calabash-android/management/app_installation'

AfterConfiguration do |config|
 
FeatureMemory.feature = nil
end

Before do |scenario|
  scenario
= scenario.scenario_outline if scenario.respond_to?(:scenario_outline)

  feature
= scenario.feature
 
if FeatureMemory.feature != feature || ENV['RESET_BETWEEN_SCENARIOS'] == '1'
   
if ENV['RESET_BETWEEN_SCENARIOS'] == '1'
      log
'New scenario - reinstalling apps'
   
else
      log
'First scenario in feature - reinstalling apps'
   
end

   
##uninstall_apps ========> comment or delete this line and save
    install_app
(ENV['TEST_APP_PATH'])
    install_app
(ENV['APP_PATH'])
   
FeatureMemory.feature = feature
   
FeatureMemory.invocation = 1
 
else
   
FeatureMemory.invocation += 1
 
end
end


make sure you have the copy ( you don't want to lose anything) and also make sure the copy is not executable under that directory( you don't want to have both of these configs running)!
That worked for me.
Reply all
Reply to author
Forward
0 new messages