如何在同一项目中具有多个Cucumber步骤定义以测试产品变体 [英] How to have multiple Cucumber step definitions in the same project for testing product variants

查看:257
本文介绍了如何在同一项目中具有多个Cucumber步骤定义以测试产品变体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为ios和android中的移动应用程序进行自动化项目. 我正在使用Java-Appium-Cucumber框架编写测试.

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

对于Android和ios,我都需要执行用户登录到应用程序"步骤.但是android和ios中的实现是不同的.所以我在android> step_definitions和ios> 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. 我不想像实现(android){doAndroidWay()} else(doIOSWay)那样对实现进行单步定义,因为那样的话我就必须检查所有方法中的平台.

  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.

我不想执行多个步骤,因为用户登录到android中的应用程序"和用户登录到ios中的应用程序"

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

还有其他方法可以消除重复的步骤def错误吗?像告诉黄瓜在从android>功能运行场景时仅在android> step_definitions中寻找步骤吗?

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 ?

感谢您的帮助.

推荐答案

如果您在android和ios之间没有任何通用的stepdefinition代码,请使用粘胶选项告诉相应的跑步者在子文件夹中查找stepdef代码.对于android,请使用'glue ="android.step_definitions"';对于ios,请使用'glue ="ios.step_definitions"'

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"'

这篇关于如何在同一项目中具有多个Cucumber步骤定义以测试产品变体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆