1

Does anyone ever tried running calabash-ios and calabash android together.

Suppose I have installed application A in android and application B on iOS and want to send some message from application A and validate that in application B.

Please let me know if anyone have done this and or any idea how to do this it will be really helpful.

Regards, Nishant Singh

  • 1 test can only control 1 target so I don't think this would be too easy. What you can do though is to launch both and build the scenario's in such a way that target 1 sends a message, and target 2 goes into to inbox or what ever and is checking if that message is received with some wait_until method. – Lasse Feb 01 '16 at 12:35
  • I am thinking the same I will try and let you know if it worked – Nishant Singh Feb 02 '16 at 06:09
  • There is nothing blocking this kind of testing. – jmoody Feb 02 '16 at 15:55
  • I have done this in the past so it is definitely possible. You have to manually configure the device drivers and then specify which driver you want to use at each step e.g. inject it into your page objects. – alannichols Feb 02 '16 at 16:11
  • If I recall correctly, ios and android both have different Device constructors in their respective operations class i.e. calabash/android/operations. I will try to dig out my old code. – alannichols Feb 02 '16 at 17:33
  • @alannichols I am newly using calabash so it would be great help if you could provide the details. Thanks – Nishant Singh Feb 03 '16 at 06:27
  • I have posted what I remember as working in an answer. If there are any issues with it let me know and I will try to help. I'll check again to try to find my old code, but hopefully what I have remembered and put in the answer is enough. – alannichols Feb 03 '16 at 16:01
  • Did you get anywhere with this? – alannichols Feb 16 '16 at 14:20
  • Sorry for late replay actually I am using two different instance of terminal window to start the executions and running test on both separately as I need only one data to be transferred from android to iOS I am waiting for that to appear on iOS then continuing with my further execution. – Nishant Singh Feb 17 '16 at 09:07
  • Right I understand. Well if you ever want to run it all from one bit of code my answer should work! :) – alannichols Feb 18 '16 at 09:41
  • 1
    @alannichols Thanks for all your help. :) – Nishant Singh Feb 18 '16 at 13:37

2 Answers2

0

This answer is from memory, so apologies if any of it is incorrect. If I can get hold of my old code I will recheck this and update if necessary.

NOTE: My experience is for doing this using real devices, so it may differ slightly for simulators.

For android you can manually configure multiple instances of the driver.

@android_app1 = Calabash::Android::Operations::Device.new(self, 'DEVICE_SERIAL1', 123, '/path/to/app', '/path/to/testserver', 456)
@android_app2 = Calabash::Android::Operations::Device.new(self, 'DEVICE_SERIAL2', 124, '/path/to/app', '/path/to/testserver', 457)

Once instantiated, you can run methods on a specific device by calling it directly

@android_app1.reinstall_apps
@android_app2.reinstall_apps

Or you can use a method to define which device is the default one that you want it to run on. Then any calabash commands will run on that device. This setting is only applicable for android and doesn't affect iOS devices in any way.

Calabash::Android::Operations.set_default_device(@android_app2)
query("* text:'thing'") # Will be run on @android_app2
Calabash::Android::Operations.set_default_device(@android_app1)
query("* text:'some_other_thing'") # Will be run on @android_app1

From what I remember for iOS, you can set up the iOS driver in the same way as you would for the case where you are only using one device that's iOS, i.e. setting environment variables. To use the iOS device you need to make sure there is a setting for one of the environment variables, I think it was DEVICE_ENDPOINT. If this environment variable is set with the iOS device's ip, then any commands from calabash will be sent to the iOS device. If it is set to an empty string then any calabash commands will be sent to the android device.

So assuming that you have the iOS environment variables all configured correctly, and that you have a constant IPHONE_IP which contains you iOS device IP.

# Start app on iOS device. Assuming you have set your env vars as per the docs.
@calabash_launcher = Calabash::Cucumber::Launcher.new
@calabash_launcher.relaunch
@calabash_launcher.calabash_notify(self)

ENV['DEVICE_ENDPOINT'] = '' # Clear this env var so that android is targeted

@android_app1 = Calabash::Android::Operations::Device.new(self, 'DEVICE_SERIAL1', 123, '/path/to/app', '/path/to/testserver', 456)
@android_app2 = Calabash::Android::Operations::Device.new(self, 'DEVICE_SERIAL2', 124, '/path/to/app', '/path/to/testserver', 457)

# Do some stuff declaring which device to act on each time.
@android_app1.reinstall_apps # Runs on @android_app1
@android_app2.reinstall_apps # Runs on @android_app2

# Do some stuff by defining which device you want to be used
Calabash::Android::Operations.set_default_device(@android_app2)
query("* text:'thing'") # Will be run on @android_app2
Calabash::Android::Operations.set_default_device(@android_app1)
query("* text:'some_other_thing'") # Will be run on @android_app1

# Now to use the iOS device
ENV['DEVICE_ENDPOINT'] = IPHONE_IP # Set so that calabash knows to use iOS device
query("* text:'thing'") # Will be run on iOS device

ENV['DEVICE_ENDPOINT'] = ''
query("* text:'thing'") # Will be run on @android_app1 as it is still set to be the default android device

I ended up making a class that dealt with this stuff for me, as it gets annoying having to add and remove the env var, and switch between devices. I also ended up moving away from the complicated cross platform multi device implementation in favour of using mocks. Hope this works for you!

alannichols
  • 1,496
  • 1
  • 10
  • 20
0

I would say this has nothing to do with calabash as the 2 processes need a way to synchronise data hence you may want to try something like this Is communication between two ruby processes possible/easy?

Community
  • 1
  • 1
Tejasvi Manmatha
  • 564
  • 7
  • 12