作为一个端到端自动化测试人员,我一直认为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 :)
这里有一些关于此的帖子
更多推荐
给定,何时,然后(给定,何时,然后,何时,然后)的黄瓜顺序
发布评论