Is it possible to share cucumber step definitions between ios and android in appium framework?

Hi All,

I need some support whether we can share same cucumber feature file and step definitions for ios and android? I tried to create 2 packages called ios and android and added same step definitions in each platform but cucumber throw with DuplicateStepDefinitionException which is understandable. I would need suggestion if anyone has done similar like sharing feature file and step definition? Or is there any good approach to avoid duplication of files?

Thank you

I’m making an assumption that your app is the same on both platforms. If not, this is a much bigger challenge.

We’ve divided the layers of our software test code with Cucumber into the following

Cucumber Feature File
Step Defs
Navigation layer
Screen Objects
Appium Driver calls

The navigation layer are composite actions taken upon a screen or screens to perform some task. You may find you want to embed those into your Step Definitions. I find it’s cleaner this way.

Your navigation layer might be different between iOS and Android if you take actions that involve operations outside of your app. If so, then you’ll detect the platform at that layer and branch accordingly. If your screen objects and navigation is all the same on both platforms, you can make the branch inside of the screen object code.

@willosser Thanks for the reply. Yes correct we have pretty much same app for both platform. And what i wanted to know is how can i smartly detect platform in step definition?

I only test with Android, so I haven’t had to face this issue, but my first thought is that I would query the capabilities I set when I started the Appium server.