【问题标题】:Identical feature on two devices but different behaviors/scenarios for BDD testing两个设备上的相同功能,但 BDD 测试的不同行为/场景
【发布时间】:2020-10-31 12:43:28
【问题描述】:

功能:作为用户,我希望能够更改熊猫的周年纪念日

我们的应用有两个版本:桌面版/移动版

在桌面上,我们必须转到熊猫的详细信息页面 -> 我们单击更改周年日期按钮 -> 弹出我们可以输入新日期的位置,我们验证并完成。它给出了这种情况:

Given the user is in the detail page of a panda    
and the user is logged  
When the user update the anniversary date of the panda  
Then the anniversary date is updated  

在移动设备上,我们必须选择菜单更改周年日期 -> 输入熊猫名称的新页面 -> 我们被发送到输入新周年日期的新页面。我们验证并完成。它给出了这种情况:

Given the user is in the Change Anniversary mode  
And a panda is selected  
And the user is logged  
When the user update the anniversary date  
Then the anniversary date is updated.   

如果我发现很容易为桌面编写场景,而对于移动设备,我可能无法选择不存在的熊猫。这种行为不能在桌面上存在,因为我们有一个熊猫列表,我们必须单击一个才能转到详细信息页面。取而代之的是,在移动设备上我们必须输入熊猫的名字,所以我们可能输入一个不存在的名字。我目前有这种情况,但我不喜欢它:

Given the user is in the Change Anniversary mode  
And the user is logged  
When the user enter a non existing panda name  
Then an error message is shown   

&

Given the user is in the Change Anniversary mode  
And the user is logged  
When the user enter an existing panda name  
Then the panda is selected 

我被阻止了,因为提供的新功能在两台设备上都是相同的。我是否需要使我的行为/场景在桌面和移动设备之间匹配,或者我的行为/场景根据平台而有所不同是否可以?如果我选择第二个选项我如何精确平台:在标题场景中还是在给定?我已经写过的所有其他场景呢?我希望有人已经找到了解决这个问题的方法:p

感谢您的帮助!

编辑:我添加了标题功能和我目前拥有的一些场景:)

【问题讨论】:

  • 您能否在您的问题中添加一些场景,以便我们了解您的意思?我分为编写不同的场景或改写您的步骤,以便它们适用于每个平台。我们没有足够的信息来回答您的问题。
  • 我添加了功能标题和我的一些场景,谢谢!

标签: testing bdd gherkin


【解决方案1】:

你的例子不是很清楚,你说On desktop we have to go to the detail page of a panda -> we click to the change anniversary date button -> pop up where we can enter the new date, we validate and it's done. It gives this scenario,但在你提到用户已登录的场景中,在需要选择熊猫之前或之后,我看不到这种情况发生在哪里。

据我所知,您有两种选择:

  1. 对于移动和桌面有不同的场景,你可以使用平台标签进行注释,例如@mobile 并基于此选项卡打开特定平台,或者只是创建不同的套件,一个用于移动设备(如果您有本机应用程序),一个用于桌面

  2. 不添加具体平台细节,在实现中处理细节

鉴于我已登录
当我更改熊猫的周年纪念日时
那么周年纪念日就变了

我的建议:如果只有很少的差异,您可以使用第二个选项,但如果您有很多差异,那么最好为移动和桌面设置不同的场景,如果您有本机应用程序,那么我会说要在不同的套件中执行它们

【讨论】:

  • 嗨!谢谢你的回答^^事实上我们确实有很多不同的移动应用场景。它不是原生的,但由于它将被不同的用户以不同于桌面应用程序的方式使用,我同意我们需要分开我们的测试。我没有提到登录,因为它在后台,就像我们除了在桌面或移动应用程序中登录之外无法做任何事情,所以我不会把它放在每个 Given 中,在 bakcground 中,它对所有其他人都有效场景^^
【解决方案2】:

由于我的行为不同,而且我的移动应用和桌面应用的用户也不同,我决定将我的场景分开,就像 lauda 所说的那样,它让我能够使用不同的解决方案来测试它是否是原生移动应用(现在不是我的情况,而是其他人^^)。

在我的项目中,移动和桌面场景在不同的文件中是分开的:

../features/anniversary_panda/desktop/

Background: Login
Given the user is logged in as a panda manager

Scenario: Change anniversary date for a panda
Given the user is in the detail page of a panda    
When the user update the anniversary date of the panda
Then the anniversary date is updated  

../features/anniversary_panda/mobile/

Background: Login
Given the user is logged in as a veterinary

Scenario: Change anniversary date for a panda
Given the user is in the Change Anniversary mode  
And a new date is already entered
When the user enter an existing panda name  
Then the anniversary date is updated

感谢您的帮助,向您解释我的情况对我有很大帮助:)

【讨论】:

    猜你喜欢
    • 2018-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多