In this chapter:
- What is test-driven development and how to apply it
- Reasons to adopt TDD
- How TDD fosters intra-team and extra-team collaboration
- Different approaches to applying TDD
- When to apply TDD and when not to
- How to create an adequate environment for TDD to succeed
- What is behaviour-driven development, how it relates to TDD, and why adopt it
Imagine that today is one of those days you woke up inspired to bake the best banoffee pies the east side of London has ever tasted. You’ve already bought all the biscuits, the bananas, tons of sugar, and the tastiest condensed milk one can find. Your industrial oven is pre-heated and ready for some serious baking.
After preparing quite a few pies, you put them in the oven, and, when the timer rings, you run straight back to the kitchen to try one. The smell is so delightful it makes your eyes gleam, but, when you try a slice, it’s not nearly as good as you’d expect.
Unfortunately, it looks like you’ve bought the wrong kinds of bananas. Besides being the wrong species, they were just like your tests should be: too green.
Imagine how frustrating would it be to bake an entire batch of banoffee pies only to find out in the end that none of them turned out to meet your expectations. After a whole batch, it’s too late to course-correct.