• Home
  • BVSSH
  • Engineering Enablement
  • Playbooks
  • Frameworks
  • Good Reads
Search

What are you looking for?

Practice : Test-Driven Development (TDD)

Purpose and Strategic Importance

Test-Driven Development (TDD) is a software development approach where tests are written before code. Developers define expected behaviour with tests, then write the minimum code to pass those tests. This loop promotes clarity, simplicity, and confidence in code quality.

TDD helps ensure that code is testable by design, drives better architecture, and builds a safety net that supports refactoring and fast iteration. It’s a key enabler of engineering excellence, continuous delivery, and technical resilience.


Description of the Practice

  • The TDD cycle: Red → Green → Refactor:
    • Write a failing test for new functionality (Red)
    • Write the simplest code to make the test pass (Green)
    • Refactor the code for clarity and maintainability (Refactor)
  • Tests guide design and validate business behaviour.
  • TDD tests are part of the CI pipeline and must run quickly and reliably.
  • Practised at the unit level, and also supports integration and behaviour testing.

How to Practise It (Playbook)

1. Getting Started

  • Choose a test framework suited to your language and ecosystem (e.g. JUnit, xUnit, Jest, PyTest).
  • Start with small functions or modules - write one test at a time.
  • Embrace the cycle: Red (failing test) → Green (passing implementation) → Refactor.
  • Run tests locally and in CI to get fast feedback on changes.

2. Scaling and Maturing

  • Apply TDD at different levels: unit, integration, and acceptance.
  • Use TDD to drive reusable, modular, and loosely coupled code.
  • Encourage pairing or mob programming to level up TDD skills.
  • Refactor tests along with production code - tests are first-class citizens.
  • Use mutation testing or coverage analysis to assess test strength.

3. Team Behaviours to Encourage

  • Write tests before code, not after.
  • Keep test cycles short - tests should execute in milliseconds or seconds.
  • Review tests like production code - clarity, intent, and maintainability matter.
  • Celebrate red-green-refactor cycles as signs of healthy engineering practice.

4. Watch Out For…

  • Writing overly broad or fragile tests that slow teams down.
  • Treating tests as optional or writing them only after features are complete.
  • Long feedback loops due to slow or flaky tests.
  • Over-reliance on code coverage without meaningful assertions.

5. Signals of Success

  • Code changes are always accompanied by meaningful, passing tests.
  • Tests fail when requirements change - and guide necessary code updates.
  • Teams refactor confidently, supported by fast feedback and test safety nets.
  • Quality and delivery speed improve over time.
  • TDD is embedded in engineering culture, not treated as an optional step.
Associated Standards
  • Failure modes are proactively tested
  • Failure patterns are used to inform architectural investment
  • Learnings from incidents are turned into engineering improvements
  • Major incidents are followed by timely, blameless reviews
  • Teams have autonomy to shape their development environments
  • Tests provide meaningful confidence in code changes

Technical debt is like junk food - easy now, painful later.

Awesome Blogs
  • LinkedIn Engineering
  • Github Engineering
  • Uber Engineering
  • Code as Craft
  • Medium.engineering