是否存在“对于每个”或Gherkin / Cucumber的等效语法? [英] Is there a "for each" or equivalent syntax for Gherkin/Cucumber?

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

问题描述

Gherkin有没有相当的for each语句?在下面的场景中,我测试的页面有多个日期字段,我想运行相同的测试示例。



这里是我想要的场景

场景概述:修改日期控件的精确度值

 给定我刚刚添加了一条记录

当我选择< precision>

我选择< value>

然后< date>显示在< date type>字段

示例:

  |日期类型|精度|值|日期| 

|日期1 |未知| N / A | 未知|

|日期1 |年| < current year> | < current year> |

|日期1 |月| < current month> | <当前月,年> |

|日期1 |日| < current day> | <当前月/日/年> |

|日期2 |未知| N / A | 未知|

|日期2 |年| < current year> | < current year> |

|日期2 |月| < current month> | < current month,year> |

|日期2 |日| < current day> | <当前月/日/年> |

假设同一页面上有5个日期类型字段。似乎没有必要在表中复制/ psate 12行覆盖日期3 - 日期5.这就是为什么我想知道是否有一个为每个等效,所以我可以为每个日期类型执行相同的示例,必须在Examples表中明确显示。



感谢您提供任何协助!

解决方案

不,黄瓜不是设计成循环的。 Cucumber的范围是允许从用户角度定义应用程序期望。而且由于真正的用户没有循环,它在黄瓜中实现没有意义。

\\ b $ b可以做到,写一个程序,为您的应用程序中的每个组合生成相同的黄瓜脚本。


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

Examples:

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

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!

解决方案

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天全站免登陆