是否有“每个人"?或 Gherkin/Cucumber 的等效语法? [英] Is there a "for each" or equivalent syntax for Gherkin/Cucumber?

查看:18
本文介绍了是否有“每个人"?或 Gherkin/Cucumber 的等效语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 Gherkin 是否有任何等效的for each"语句?在以下场景中,我正在测试的页面有多个日期字段,我想在这些字段上运行相同的测试示例.

Is there any equivalent "for each" statement for Gherkin? In the following scenario, the page I am testing has multiple date fields that I'd like to run the same test examples on.

这是我想要建模的场景.

Here is the scenario that I would like to model.

场景大纲:修改日期控件的精度值

Scenario Outline: Modify precision values for date controls

Given I have just added a record

 When I select <precision>

  And I select <value>

 Then <date> displays in the <date type> field

例子:

  | date type | precision | value           | date                     |

  | Date 1    | Unknown   | N/A             | "Unknown"                | 

  | Date 1    | Year      | <current year>  | <current year>           |

  | Date 1    | Month     | <current month> | <current month, year>    |

  | Date 1    | Day       | <current day>   | <current month/day/year> | 

  | Date 2    | Unknown   | N/A             | "Unknown"                | 

  | Date 2    | Year      | <current year>  | <current year>           | 

  | Date 2    | Month     | <current month> | <current month, year>    | 

  | Date 2    | Day       | <current day>   | <current month/day/year> | 

假设同一页面上有 5 个日期类型字段.似乎没有必要在表格中再复制/psate 12 行来覆盖日期 3 - 日期 5.这就是为什么我想知道是否有一个for each"等价物,这样我就可以对每个日期类型执行相同的示例,而无需必须在示例表中明确显示.或者也许我可以用不同的方式来构建场景?

Suppose there are 5 date type fields on the same page. It seems unnecessary to have to copy/psate 12 more rows in the table to cover Date 3 - Date 5. That's why I was wondering if there is a "for each" equivalent so that I can perform the same examples for each date type without having to explicitly show that in the Examples table. Or perhaps there is a different way I could structure the scenario?

感谢您提供的任何帮助!

Thanks for any assistance you can provide!

推荐答案

不,cucumber 在设计时并没有考虑到循环.Cucumber 的范围是允许从用户的角度定义应用程序的期望.而且由于真正的用户不会循环",所以在 cucumber 中实现它是没有意义的.

从编程上讲,可以做的是编写一个程序,为应用程序中的每个组合生成相同的黄瓜脚本.

Nope, cucumber is not designed with looping in mind. Cucumber's scope is to allow defining application expectancies from a user perspective. And since real users don't "loop", it doesn't make sense to have it implemented in cucumber.

What can be done, programatically speaking, is to write a program that generates the same cucumber scripts for every combination in your application.

这篇关于是否有“每个人"?或 Gherkin/Cucumber 的等效语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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