黄瓜长?
我正在为多步骤注册过程创建 Cucumber 测试,并且有点不确定场景步骤的最佳实践...
注册中有 4 个表格/页面。我应该循环遍历给定、何时和吗?那么在一个场景中 4 次还是有更好的方式来组织它?
到目前为止,我已经...
Scenario: Company User
Given I am on the registration page
When I follow "Register as a supplier"
When I fill in the following:
| user_email | [email protected] |
| user_password | secret |
| user_password_confirmation | secret |
And I press "Create login - Proceed to step 2"
Then I should see "Create Company Profile"
When I fill in the following:
| company_name | Test Company |
| company_description | Lorem |
| company_telephone | 01928740436 |
| company_email | [email protected] |
And I press "Create company - Proceed to step 3"
Then I should see "Test Company office(s)"
I am creating a Cucumber test for a multistep registration process and am a little unsure about the best practice for the Scenario Steps...
There are 4 forms / pages in the registration. Should I loop through the Given, When & Then 4 times in the one scenario or is there a better way to organise it?
So far, I have got...
Scenario: Company User
Given I am on the registration page
When I follow "Register as a supplier"
When I fill in the following:
| user_email | [email protected] |
| user_password | secret |
| user_password_confirmation | secret |
And I press "Create login - Proceed to step 2"
Then I should see "Create Company Profile"
When I fill in the following:
| company_name | Test Company |
| company_description | Lorem |
| company_telephone | 01928740436 |
| company_email | [email protected] |
And I press "Create company - Proceed to step 3"
Then I should see "Test Company office(s)"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为 Andy Waite 给出了很好的建议,但不是像步骤 1、步骤 2 等通用名称。我会更具描述性:
I think Andy Waite has given good advice, but rather than generic names like step 1, step2, etc. I would be more descriptive:
我建议使用 4 个场景来涵盖每个步骤的细节,例如:
您可以在“假设我正在进行 X 步”的定义中隐藏任何必要但不相关的表单填写。
您可能还应该有一个涵盖所有内容如何组合在一起的场景,例如:
I would recommend having 4 scenarios covering the detail of each step, e.g:
You can hide away any necessary but irrelevant form-filling within the definition of "Given I am on step X".
You should probably also have a scenario which covers how everything fits together, e.g.:
我喜欢 Mark Irvine 的建议——Cucumber 自动化的主要概念之一是编写对读者尽可能清晰的步骤。即使对于根本不是程序员的人来说,测试正在做什么也应该绝对清楚。
如果您有兴趣,您还可以阅读 Matt Wynne 撰写的《The Cucumber Book - Behaviour-Driven-Development for testers and Developers》,了解更多良好实践。
问候,
亚历克斯
I like Mark Irvine`s suggestion - one of the main concepts of Cucumber automation is to write steps that are as clear to the reader as possible. It should be absolutely clear what the test is doing even to a person that is not programmer at all.
If you are interested - you can also read "The Cucumber Book - Behaviour-Driven-Development for testers and Developers" by Matt Wynne for more good practices.
Regards,
Alex