Acceptance Test Styles
Imperative vs Declarative
Leeds Tester Gathering – April 2013
Alan Parkinson
Given a user “alan" exists with password "secret"
And I am not logged in
When I navigate to the home page
Then I am redirected to the login form
When I enter the “username” with “alan”
And I enter the “password” with “secret”
And I press “login”
Then I am redirected to the home page
Given I am an unauthenticated User
When I attempt to view some restricted content
Then I am asked to authenticate
When I authenticate with valid credentials
Then I am shown the restricted content
Summary
• Write in the Declarative style
– Your scenario doesn’t become brittle
– The business will read it
• Avoid unnecessary detail
– Don’t tie your scenario to the UI
– Using sensible default values
– Override the defaults where required
Questions and Answers
alan.parkinson@hindsightsoftware.co.uk
@alan_parkinson @TeamHindsight
Alan Parkinson
CEO and Co-founder Hindsight Software Ltd

Acceptance test styles - Imperative vs Declarative

  • 1.
    Acceptance Test Styles Imperativevs Declarative Leeds Tester Gathering – April 2013 Alan Parkinson
  • 4.
    Given a user“alan" exists with password "secret" And I am not logged in When I navigate to the home page Then I am redirected to the login form When I enter the “username” with “alan” And I enter the “password” with “secret” And I press “login” Then I am redirected to the home page
  • 5.
    Given I aman unauthenticated User When I attempt to view some restricted content Then I am asked to authenticate When I authenticate with valid credentials Then I am shown the restricted content
  • 6.
    Summary • Write inthe Declarative style – Your scenario doesn’t become brittle – The business will read it • Avoid unnecessary detail – Don’t tie your scenario to the UI – Using sensible default values – Override the defaults where required
  • 7.
    Questions and Answers alan.parkinson@hindsightsoftware.co.uk @alan_parkinson@TeamHindsight Alan Parkinson CEO and Co-founder Hindsight Software Ltd

Editor's Notes

  • #4 Command driven,List of instructions, how to do somethingDescribes what to do but not how to do it how
  • #5 Boring - doesn’t engage the business peopleTied to the UI Brittle to UI changes Mobile, thick client, Web appBrittle to implementation changes Change the authentication mechanism
  • #6 Easy to read – The business will get involved – They can write this!No longer tied to the UI UI changes can be updated in the steps or Page Object pattern Reuse across different UI’s - Mobile, thick client, Web appNo longer brittle to implementation changes Change the authentication mechanism