【发布时间】:2018-08-06 03:38:52
【问题描述】:
据我了解,基于此Given When Then wiki page,Given 步骤与应用程序交互以设置前置条件状态,When 步骤与应用程序交互以尝试设置正在测试的所需新状态,以及 @987654328 @ 语句读取应用程序的状态而不修改它。
将When 步骤作为Given 步骤重复用于后续状态是否是个好主意?
例如,在一个简单的购物车应用程序中,我可能会这样写:
Given the user is interested in some item
When the user adds the item to their cart
Then the cart will include the item
Given the user adds the item to their cart
When the user checks out
Then the user will see a summary of their purchase including the item
Given the user checks out
When the user cancels an item
Then the item should be canceled
And the user should be refunded
这里有一个类似的问题reusing the user's previous interaction in a wizard,但它似乎与Uncle Bob's finite-state-machine interpretation 不同意,因为答案建议使步骤不那么严格,而鲍勃叔叔暗示这些步骤应该足够严格以使人理解状态转换图出来。我完全接受删除所有用户界面行话并只关注业务术语的建议,但在逻辑上连接业务术语之间似乎确实存在差异,就像我在这里尝试做的那样,只是做出逻辑上不可连接的步骤仅通过“看不见”的胶水代码连接。
【问题讨论】:
-
试试qmetry.github.io/qaf/latest/gherkin_client.html,它提供了最大程度的可重用性,并且还支持 jar 中的步骤。参考github.com/qmetry/qaf-step-by-step-tutorial/wiki
标签: cucumber cucumber-jvm gherkin