Specifying the what rather than the how with Cucumber

Recently Gojko Adzic held the latest London Agile Testing Group at Skillmatter in Farringdon and talked about Cucumber. I couldn’t make it but caught the video online (http://skillsmatter.com/podcast/agile-testing/using-cucumber-for-bdd-and-agile-acceptance-testing).

Gojko comments on how Cucumber allows us to concentrate on the what rather than the how, when compared to other acceptance testing tools. The same day I had a conversation with a former colleague

Describing the how

He was telling me about a tester on his project that was writing a Cucumber spec but failing to portray any business/customer value. I wasn’t sure what he meant so he sent over the feature file and I had a look. Here’s an example below (with the domain changed).

Feature: Customers can purchase products in their basket.
So that I can purchase the products I accumulate in my basket
As the customer
I want to be able to pay for them at a checkout.

Scenario: Filling out valid details at the checkout.
Given I am on the checkout page
When I fill in “Mr” for “Title”
And I fill in “Another” for “Firstname”
And I fill in “Tester” for “Surname”
And I fill in “111” for “House Number”
And I fill in “Buckingham Palace Road” for “Street Name”


You can see where this is going…

The Given, When and Then statements are being used to describe how he wants to test the feature and not what he wants it to do (or behave).

Seeing this notation reminded me of my QTP days, where I was on a ‘QA’ team writing automated tests that no one else apart from us would use or even understand. These tests would never describe the business rule that was being verified and were usually made up of long scripts of basic web-page interactions, e.g:

Browser(“Some website”).Page(“Some page”).WebEdit(“Some box”).Set “Some value”
Browser(“Some website”).Page(“Some page”).Link(“This is bringing back painful memories”).Click


Same story.

Describing the what

His tester friend could better reflect the business rules and behaviour of the feature by being more expressive; e.g:

Scenario: Filling out valid details at the checkout.
Given I have a product in my basket
When I go through the checkout with valid details
Then I should be thanked
And I should receive a confirmation e-mail

And onto different scenarios

Scenario: Filling out invalid details at the checkout.


More descriptions about behaviour…

Imagine that scenario failed if it were part of your regression effort… Not only would you know what was wrong but you’d immediately know the impact it has because the business value is expressed in plain English.

As Gojko mentions in his talk, Cucumber is “one of the rare tools that goes a long way to stay out of your way, (it) lets you do your work and not have to worry about the tool itself”. Spot on.

Advertisements

0 Responses to “Specifying the what rather than the how with Cucumber”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: