给定,何时,然后(给定,何时,然后,何时,然后)的黄瓜顺序 [英] Cucumber ordering of Given, When, Then (Given, When, Then, When, Then)

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

问题描述

作为一个端到端自动化测试人员,我一直认为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.

即不应进行测试,例如,给定,何时,然后,何时,然后.相反,应遵循给定,何时,仅然后".

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.

但是,我在网络上的一些小黄瓜示例中注意到它们有时使用以下顺序:给定,何时,然后,何时,然后.

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

有人知道写完那么"后是否回到何时"是可以接受的最佳实践?我赞赏该测试仍然有效,只是想知道这是好还是坏的做法.

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.

一个原因是何时声明一个动作,然后然后验证该动作的结果.拥有时间-然后两次违反了方案的个别行为.

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

这里有一些关于此的帖子

这篇关于给定,何时,然后(给定,何时,然后,何时,然后)的黄瓜顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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