Monday, 10 January 2011

What is Given-When-Then anyway?

I’ve been asked several times what a working set of Given-When-Then examples looks like in practice. The full style is not just the GWT component, though I have used that on its own. In full we might be having a Scenario followed by one or more Features with one or more Examples.

Here’s what a set might look like, based on some recent testing of Microsoft Office Communicator Group Chat. However, this could apply to any chat client or forum board.

You’ll see we have one Scenario that is the goal the business wants to achieve. To achieve it the software has to have a collection of Features (aka functionality) and to prove those Features are there we have Examples (of behaviour the system can enact – my definition of Functionality*)

Hopefully you’ll see how ‘obvious’ they are to any reader in any team due to the narrative format.
--
Scenario: Once the user has joined one of the Chat Rooms available to them they need to be able to read existing messages. These can include text, links, stories, files and images.

Feature: A user can see persisted and new messages in a Chat Room they have just joined
AS A user who has just joined a Chat Room
I WANT to see messages other participants are posting now and have posted in the last days
SO THAT I can read messages shared in previous days or being shared right now

Example: The user enters a Chat Room that has several days’ worth of messages
GIVEN the Chat Room has messages posted over the last days
WHEN I Join the Chat Room
THEN I can see the messages for the last days with a date stamp against them

--
Feature: A user can view attachments, links, images and stories contained within messages
AS A user viewing messages that contain more than simple text
I WANT to be able to open them and see the contents
SO THAT I can view the additional information and understand the message fully

Example: The user opens a message that contains a file attachment or story
GIVEN the message contains a file attachment or story
WHEN I click the message link to open the message
THEN the message opens and shows the attached file or story

Example: The user opens a message that contains a link
GIVEN the message contains a link
WHEN I click the message link to open the message
THEN the message opens and shows the link as an active hyperlink

Example: The user opens a message that contains an image
GIVEN the message contains an image attachment
WHEN I click the message link to open the message
AND hover my mouse of the image file posted in the message
THEN the image can be viewed as a thumbnail

1 comments: