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

查看:29
本文介绍了如何在同一项目中有多个 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.

下面是我的项目结构

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.

附注:

  1. 我不想像 if(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'

有没有其他方法可以消除重复的 step def 错误?就像告诉黄瓜在从 android > features 运行场景时只在 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代码,那么使用glue选项告诉各自的runner在子文件夹中寻找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天全站免登陆