Consumer Driven Contract Testing demo using Pact
-
Find a pair to do the exercise with
-
If you are doing this exercise remotely:
-
Each of you needs to install Tuple and register with your Zuhlke email address!
-
Ask Kevin for the magic team link
-
Start a call
-
-
Read the Etiquette for Pair Programming
-
Choose a technology for the Consumer you are going to write
-
Choose a technology for the Provider you are going to write
You'll be practising writing API contracts by using PACT in the language/tech-stack of your choice.
-
Start implementing the Consumer incrementally by using PACT and once you have a working test/contract for one of the specifications share the contract with the Provider.
-
Run the contract you just been given from the Consumer against the Provider and try to make it pass.
-
Repeat the process as you implement more and more of the specification.
Inspired by TODO-Backend API, todomvc and TodoMVC Scenarios.
Given an empty Todo list
When I add a Todo for ‘Buy cheese’
Then only that item is listed
And the list summary is ‘1 item left’
And the list’s filter is set to ‘All’ with ‘Completed’ & ‘Active’ unset
And ‘Clear completed’ is unavailable
Given an empty Todo list
When I add Todos for ‘Buy cheese’ & ‘Wash the car’
Then only those items are listed
And the list summary is ‘2 items left’
And the list’s filter is set to ‘All’ with ‘Completed’ & ‘Active’ unset
And ‘Clear completed’ is unavailable
Given a Todo list with items ‘File taxes’ & ‘Walk the dog’
When the first item is marked as complete
Then only the second item is listed as active
And the list summary is ‘1 item left’
And ‘Clear completed’ is available
Given a Todo list with items ‘File taxes’ & ‘Walk the dog’
And the first item is completed
When the filter is set to ‘Active’
Then only the second item is listed
And the list summary is ‘1 item left’
And ‘Clear completed’ is available
And the route is /active
Given a Todo list with items ‘File taxes’ & ‘Walk the dog’
And the first item is completed
And the second item is completed
When the filter is set to ‘Active’
Then nothing is listed
And the list summary is ‘0 items left’
And ‘Clear completed’ is available
And the route is /active
Given a Todo list with items ‘File taxes’ & ‘Walk the dog’
And the first item is completed
When the filter is set to ‘Completed’
Then only the first item is listed
And the list summary is ‘1 item left’
And ‘Clear completed’ is available
And the route is /completed
Given a Todo list with items ‘File taxes’ & ‘Walk the dog’
And the first item is completed
When ‘Clear completed’ is clicked
Then only the second item is listed
And the list summary is ‘1 item left’
Given a Todo list with items ‘File taxes’ & ‘Walk the dog’
When the clear all items affordance is toggled
Then both items are listed
But nothing listed is active
And the list summary is ‘0 items left’
Given a Todo list with items ‘File taxes’ & ‘Walk the dog’
And the first item is completed
When the clear all items affordance is toggled
Then both items are listed
But nothing listed is active
And the list summary is ‘0 items left’
Given a Todo list with items ‘File taxes’ & ‘Walk the dog’
And the first item is completed
And the second item is completed
When the clear all items affordance is toggled
Then both items are listed
And both are active
And the list summary is ‘2 items left’
Given a Todo list with a single item ‘File taxes’
When the item is removed
Then nothing is listed
Given a Todo list with single item ‘File taxes’
When the item is selected for edit
Then the item cannot be completed
And the item cannot be removed
Given a Todo list with a single item ‘File taxes’ When the item is selected for edit
And the Todo is changed to ‘Apply for 6-month tax extension’
Then only the revised item is listed
Given a Todo list with a single item ‘File taxes’
And that item is being edited
When editing is abandoned
Then only that item is listed
And the list summary is ‘1 item left’