Writing tests prevents errors from the start

Topics: Testing

The cited passage argues that writing tests alongside code can catch mistakes and reduce debugging.

By writing what I want twice, in the code and in the test, I have to make the mistake consistently in both places to fool the detector. By double-checking my work, I reduce the chance of doing something wrong. Although it takes time to build the tests, I end up saving that time, with considerable interest, by spending less time debugging. (Martin Fowler, Refactoring)