Wednesday, April 24, 2013

Introduction to BDD/TDD - Behaviour Driven Development and Test Driven Development

Behaviour Driven Development started as an attempt to better understand and explain the process of Test Driven Development.

Test Driven Development is a developer practice that involves writing tests before writing the code being tested. Start by writing a very small test for code that does not yet exist. Run the test and it will fail. Then write enough code to make that test pass. That's the idea!

Not all projects have QA or testing teams, and these methodologies and practices help balance the risk and overall quality of the software being built.

As a developer, it helps to think about all the things that could go wrong with any specific code. This is where you start adding edge or boundary cases for the behavior of your code.

TDD arrives to a point in where some confusion with Unit Testing arises, and certain details create a dependency between the internal structure of the object being tested and the test itself. This, as you can imagine, causes a lot of pain to maintain, and is a reason for test suites to become ignored.

BDD tries to come out of this as an improved way to perform "TDD". The problem with TDD is that it tests what the object is and not what it does. What it does is more important.

This evolution on testing methodologies explained that the test should focus on the behavior of what needs to be done, and not the structural-specific details.

With these, frameworks that encourage focusing on behavior instead of internal structure or values inside the object being tested emerged, such as RSpec. To use it, you need to have some basic knowledge of the Ruby programming language.

No comments:

Post a Comment