This document provides rules for applying test-driven development (TDD) to legacy code. It discusses:
- Using a bottom-up (inside-out) approach rather than top-down when working with legacy code.
- Only testing the modified code, not writing tests for all use cases of legacy code.
- Testing requirements of new code rather than all behaviors and use cases.
- Injecting new testable code into legacy code without changing it.
- Breaking hidden dependencies to decrease coupling and increase cohesion.
The document provides examples of applying each rule through code snippets from a sample e-commerce application. It aims to help structure new code for testability while minimizing changes to