Chapter 1. Test-Driven Development Practices

In this chapter, we define test-driven development (TDD) and then describe a process for applying it when developing software.

What Is Test-Driven Development?

Kent Beck, in his book Test-Driven Development: By Example (Addison-Wesley Professional, 2003), defines test-driven development using the following rules:

  • Never write a single line of code unless you have a failing automated test.

  • Eliminate duplication.

The first rule is straightforward: don’t write code without having a failing automated test because the tests embody the requirements that the code must satisfy, as stated in the Introduction. If there is no requirement (that is, test), there is no need to implement anything. This rule prevents us ...

Get Test-Driven Development in Microsoft® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.