Test-Driven Development

Test-Driven Development

TDD is a lightweight programming methodology that emphasizes fast, incremental development and especially writing tests before writing code. Ideally these follow one another in cycles measured in minutes.

Functionality is added in very small chunks. Typically the first cycle will deal with utterly simple cases: you test what happens when you are out of stock, when the quantity ordered is zero, when the list is empty, when a string has no characters in it, when the user just hits [Enter]. Once you have these very simple tests working, you add more functionality, a bit at a time.
(excerpted from http://www.testdriven.com )

Also see book by Kent Beck: "Test Driven Development: By Example"