How to structure E2E tests with Appium/Cucumber for Xamarin Forms?

JoseLuisCluaJoseLuisClua USMember ✭✭
edited July 2018 in Xamarin.Forms

We are starting to structure our UI e2e tests using Appium / Cucumber / Ruby stack.
Since we are using Xamarin Forms we obviously want to test for iOS and Android.
In the end we want to upload the tests to App Center to run in several devices, get the reports and etc.

Cucumber normally uses this directory structure:

E2E
----FEATURES
--------SUPPORT
------------env.rb
------------hooks.rb
--------STEP_DEFINITIONS
------------home_steps.rb
--------Home.feature

The problem starts with the env.rb file, that contains all the Appium desired capabilities and they are completely different or iOS and Android.

1 - How we could switch env.rb from one platform to another in a practical way?

The features and step definitions will be mostly the same for both platforms but will eventually have differences, for example testing the back button behaviour in Android.

2 - Can we create some kind of PLATFORM global variable and create conditions, for example IF PLATFORM = ANDROID THEN ... in our step definitions and features?

Another approach would be to completely separate the source code for each platform, something like this:

E2E
----iOS
--------FEATURES
------------SUPPORT
----------------env.rb
----------------hooks.rb
------------STEP_DEFINITIONS
----------------home_steps.rb
------------Home.feature
----ANDROID
--------FEATURES
------------SUPPORT
----------------env.rb
----------------hooks.rb
------------STEP_DEFINITIONS
----------------home_steps.rb
------------Home.feature

This approach would have a much cleaner code without conditions for each platform but obviously the downside is that we would have to write all tests twice.

3 - Which approach do you think is better?

Thanks

Sign In or Register to comment.