开发者

Cucumber Length?

开发者 https://www.devze.com 2023-03-06 01:33 出处:网络
I am creating a Cucumber test for a multistep registration process and am a little unsure about the best practice for the Scenario Steps...

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: Com开发者_JS百科pany 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)"


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 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 | info@agency.com |
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"


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

0

精彩评论

暂无评论...
验证码 换一张
取 消