How to have multiple Cucumber step definitions in the same project for testing product variants

二次信任 提交于 2019-12-24 08:25:39

问题


I'm working on an automation project for a mobile app in ios and android. I'm using Java-Appium-Cucumber framework for writing tests.

Below shows my project structure

src

 android

  features

  step_definitions

 ios

  features

  step_definitions

I need a step "User logins to the app" for both android and ios. But the implementation in android and ios are different. So I wrote two step definitions in android > step_definitions and in ios > step_definitions.

But this results in duplicate step definition error.

PS:

  1. I do not want to have a single step definition with implementation as if(android) {doAndroidWay()} else (doIOSWay), because then I would have to check platform in all methods.

  2. I do not want to have multiple steps as 'User logs into the app in android' and 'User logs into the app in ios'

Is there any other way to get rid of duplicate step def error? Something like tell cucumber to look for steps only in android > step_definitions when running a scenario from android > features ?

Any help is appreciated.


回答1:


If you do not have any common stepdefinition code between android and ios, then use the glue option to tell the respective runners to look for the stepdef code in the subfolders. For android use 'glue="android.step_definitions"' and for ios use 'glue="ios.step_definitions"'



来源:https://stackoverflow.com/questions/50434778/how-to-have-multiple-cucumber-step-definitions-in-the-same-project-for-testing-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!