Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber Length?

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)"
like image 364
Edward Ford Avatar asked May 16 '11 15:05

Edward Ford


2 Answers

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"
like image 187
Mark Irvine Avatar answered Sep 28 '22 20:09

Mark Irvine


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"
like image 23
Andy Waite Avatar answered Sep 28 '22 20:09

Andy Waite