Given, When, Then (Given, When, Then, When, Then) 的黄瓜排序 [英] Cucumber ordering of Given, When, Then (Given, When, Then, When, Then)

查看:23
本文介绍了Given, When, Then (Given, When, Then, When, Then) 的黄瓜排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个端到端自动化测试人员,我一直认为 Given、When、Then 语句(在使用 Cucumber 时包含在 Gherkin 语言中)只应该以 1. Given, 2. When, 3 的顺序出现. 然后.

As an End-to-end Automation Tester I have always assumed that Given, When, Then statements (incorporated in the Gherkin Language when using Cucumber) should only ever appear in the order of 1. Given, 2. When, 3. Then.

即测试不应遵循,例如,Given、When、Then、When、Then.而是应该遵循 Given, When, Then only.

i.e. A test should not follow, for example, Given, When, Then, When, Then. And instead should follow Given, When, Then only.

这种假设的原因是单次测试只测试应用程序的一个区域.

The reason for this assumption was along the lines of a single test only testing one area of the application.

但是,我注意到网络上的一些小黄瓜示例,它们有时使用以下顺序:Given、When、Then、When、Then.

However, I noticed on some gherkin examples on the web, that they use the following ordering sometimes: Given, When, Then, When, Then.

有谁知道在编写 Then 后回到 Whens 是否是可接受的最佳实践?我很感激测试仍然有效,只是想知道这是好的还是坏的做法.

Does anyone know if this moving back to Whens after writing a Then is acceptable best practice? I appreciate the test will still work, just wondering if this is good or bad practice.

推荐答案

虽然场景可以这样写,但这不是最佳实践.就我个人而言,我犯了这个错误,这可能会导致报告和维护出现问题.

Although scenarios can be written in that way, it is not best practice. I for one, have made that mistake and it can cause problems in reports and maintenance.

一个原因是 When 声明了一个动作,而 Then 验证了该动作的结果.有When - Then 两次与场景的个人行为背道而驰.

One reason would be that When declares an action and Then verifies the result of that action. Having When - Then twice goes against the individual behavior of a scenario.

阅读场景的人也会感到困惑:)

Can also get confusing for someone who reads the scenario :)

这里有一个关于此的 帖子

这篇关于Given, When, Then (Given, When, Then, When, Then) 的黄瓜排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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