7 Test-driven development

 

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.

7.1 The philosophy behind test-driven development

 

7.1.1 What test-driven development is

 
 
 
 

7.1.2 Adjusting the size your iterations

 
 
 

7.1.3 Why adopt test-driven development

 
 
 

Test-driven development reduces costs

 
 

7.1.4 When not to apply test-driven development

 
 
 
 

7.2 Writing a JavaScript module using TDD

 
 
 

7.3 Testing top-down versus testing bottom-up

 
 
 

7.3.1 What bottom-up and top-down testing mean

 
 

7.3.2 How top-down and bottom-up approaches impact a test-driven workflow

 
 
 

7.3.3 The pros and cons of bottom-up versus top-down approaches

 
 

7.4 Balancing maintenance costs, delivery speed and brittleness

 
 

7.4.1 Test-driven implementation

 
 

7.4.2 Test-driven maintenance

 
 

7.5 Setting up an environment for TDD to succeed

 
 
 

7.5.1 Team-wide adoption

 

7.5.2 Keeping distinct lanes

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest