Test-driven development (TDD) involves writing unit tests before production code to reduce defects and debugging time. The three rules of TDD are: 1) write failing tests before production code, 2) only write enough test code to fail initially, and 3) only write enough production code to pass failing tests. TDD results in production code that is well-tested, easier to change over time, and protected from inadvertent errors through automated tests. An example bowling game scorekeeper demonstrates TDD in practice.