黄瓜长度?

Edw*_*ord 5 testing ruby-on-rails cucumber

我正在为多步注册过程创建一个Cucumber测试,并且对于场景步骤的最佳实践有点不确定......

注册中有4个表格/页面.我应该在一个场景中循环使用Given,When&Then 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 | test@test.com |
  | 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 | info@agency.com |
And I press "Create company - Proceed to step 3"
Then I should see "Test Company office(s)"
Run Code Online (Sandbox Code Playgroud)

Mar*_*ine 5

我认为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"
Run Code Online (Sandbox Code Playgroud)


And*_*ite 2

我建议使用 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 | info@agency.com |
And I press "Create company - Proceed to step 3"
Then I should see "Test Company office(s)"
Run Code Online (Sandbox Code Playgroud)

您可以在“假设我正在进行 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"
Run Code Online (Sandbox Code Playgroud)