Behaviour Driven Development (BDD) is a way of working which fits naturally into Agile.
When a story is created and added to the backlog it should have some sort of acceptance criteria attached to it. These acceptance criteria have to be met in order for the story to be considered complete. In order to test these criteria it is necessary to create tests that run when any code is checked into the repository. This way, if any code breaks the tests, you know the intended functionality of the code change has unintended consequences.
The tests are written first that and they must describe and match the acceptance criteria. The tests are written in common language. So if you are English speaking, the tests are written in English. There are special text parsers that make this possible (see below). The tests usually have some form of client (calling code) that tests the interfaces of the product. These are similar to integration tests and are not as fine grained as Unit tests.
The code is then written after the tests and considered complete when the tests pass.
BDD is a good practice because it directly ties in the code that is written to the stories requested by the product owner and ensures that only code needed to fulfil the requirement is worked on. It also allows for early integration of services and early interface testing, both of which give the team feedback quickly about progress and breaking changes.
Another bonus you get from BDD is that you can use a tool such as Pickles document creator to create living documents that describe what your services actually do. Traditional documentation is often out of date by the time it is created and sometimes never implemented at all. Using a live documentation writer ensures documentation is always current.
The parser takes the tests and creates documents out of them. You can add tags into the properties of the tests to highlight and format for a wiki. As the tests are run, you can take the result of a test and publish this against the documentation. This will give you a report on exactly what your latest code base does and which bits are currently working.
I have used two tools for parsing common language into tests. I can recommend both of these tools. There are many more but these have worked well in large scale service deployment across multiple teams with Product Owners who are not very technical.
Cucumber is one of the original BDD tools and has the advantage of being cross platform. It is written in the Ruby programming language.
Specflow is a .NET plug in for visual studio. The tests are created using visual studio and are translated by the Specflow parser. They are translated into an underlying test framework like NUnit or MSTest.
To find out more visit the Specflow website.
I have hosted many training sessions, discussions and brown bags on BDD and encouraged all the teams I work with to use Test Driven Development and Behavioural Driven Development.
If you enjoyed this article, you might like to read 5 Key Agile Coaching Techniques to Try next.