问题
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:
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.
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