mercredi 25 novembre 2009

Behaviour Driven Development at Zenika

I have assisted to the Zenika's conference about Behaviour Driven Development given by Mauro Talevi from Agilesque.

The presentation was mainly decomposed in 3 parts : Introduction to BDD, Presentation of JBehave (the API used to do BDD in java) and return on experience about a real project.

Introduction to BDD.

BDD brings together Test Driven Development and Domain Driven Design by
- describing behaviour is a better form of testing
- describing needs from from point of view of it's stakeholder

BDD relies on the use of a specific language to help communication between the business, developers, testers, analysts and managers. It improves presentation.
Behaviours are described by scenarios with a why ? the value, a who ? the actor and the what ? the feature.
BDD introduce a grammar of steps GIVEN a context, WHEN there is an event, THEN produce an outcome AND do other steps.
BDD offers step parametrisation, aliases for changing language or tabularisation for changing parameters for a given scenario.
Behaviours can also become regression tests.

Example of scenario (from wikipedia) : Refunded items should be returned to stock
Given a customer buys a black jumper
and I have three black jumpers left in stock
when he returns the jumper for a refund
then I should have four black jumpers in stock

See more info here :
http://en.wikipedia.org/wiki/Behavior_Driven_Development
http://behaviour-driven.org/

Use of Jbehave.
http://jbehave.org/introduction/

Jbehave is based on Java with command line, IDE and Web integration.
It supports classic parameters type and Custom for business objet (by implementing ParameterConverter).
The association with the project code is done with annotation and the scenario data are organised in table.
It provides a layer for web testing tool (Selenium for example).
There is a small tutorial here : http://jbehave.org/documentation/two-minute-tutorial/.

Retrospective from real project experience.

The good :
communication with scenario
confidence by making behaviours more readable and visible
allows aggressive re-factoring
Tool integration allowing developer to run scenarios before commit
Web runner allowing separates testing from development environment
pairing is very valuable between tester, developer and business

The bad :
Data formats don't re-factor well (XML, CSV) especially for large data-set
finding the « then » : best form of verification can be tricky for data-centric scenario
Developer are not behaviour driven
Scenario data can become unmanageable. Cut & paste is easy temptation.
Need times to improve scenarios

The conclusion from Mauro Talevi is that BDD represents a new paradigm : very useful and simple but not always as easy and needs time.

A good presentation in french : http://www.slideshare.net/ehsavoie/at2009-soigner-sa-schizophrenie-12

Aucun commentaire: