黄瓜长?

发布于 2024-11-07 17:09:03 字数 984 浏览 1 评论 0原文

我正在为多步骤注册过程创建 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一身骄傲 2024-11-14 17:09:03

我认为 Andy Waite 给出了很好的建议,但不是像步骤 1、步骤 2 等通用名称。我会更具描述性:

When I register as a supplier with valid information
And I create company profile with valid information
And I ... with valid information
And I ... with valid information
Then I should see "Thank you for registering"

I think Andy Waite has given good advice, but rather than generic names like step 1, step2, etc. I would be more descriptive:

When I register as a supplier with valid information
And I create company profile with valid information
And I ... with valid information
And I ... with valid information
Then I should see "Thank you for registering"
趴在窗边数星星i 2024-11-14 17:09:03

我建议使用 4 个场景来涵盖每个步骤的细节,例如:

Given I am on step 2
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)"

您可以在“假设我正在进行 X 步”的定义中隐藏任何必要但不相关的表单填写。

您可能还应该有一个涵盖所有内容如何组合在一起的场景,例如:

When I complete step 1 with valid information
And I complete step 2 with valid information
And I complete step 3 with valid information
And I complete step 4 with valid information
Then I should see "Thank you for registering"

I would recommend having 4 scenarios covering the detail of each step, e.g:

Given I am on step 2
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)"

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

When I complete step 1 with valid information
And I complete step 2 with valid information
And I complete step 3 with valid information
And I complete step 4 with valid information
Then I should see "Thank you for registering"
半暖夏伤 2024-11-14 17:09:03

我喜欢 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文