Testing Is … Better Than Debugging
The Testivus “manifestivus” says Testing Beats Debugging:
We believe that time invested writing and running tests is better than time spent debugging.
The Google Testing Blog is headlined by a graphic that states:
Debugging Sucks. Testing Rocks.
I agree wholeheartedly. Debugging is a fact of development life1. It even has its own rewards, such as the sense of achievement when you find and squish a particularly nasty bug. Simply put, however, debugging is a massive waste of time2. Any time spent debugging could otherwise have been spent actually writing code, or otherwise being productive. Ergo, anything that helps to reduce the amount of time spent debugging is a Good Thing.
Testing reduces time spent debugging in various ways:
- Well-crafted assertions in your tests will narrow bugs down right to the source. Operating at the unit test level in particular is more precise than manual testing.
- Automated tests catch problems early in the development cycle, when they are easier to debug. It is well known that the earlier a problem is found, the easier it is to fix.
- Regression tests catch problems that have been debugged before, so you don’t need to debug them again. This is particularly powerful in complex areas where bugs pop up frequently.
So, if you embrace testing, you can spend less time debugging and more time doing what you enjoy: writing great code ;).
–
1 At least until we start writing perfect code…
2 Note that is debugging, not using a debugger: they are quite different.









April 5th, 2007 at 3:12 am
More testing doesn’t mean less debugging. Read the following:
http://beust.com/weblog/archives/000437.html
April 5th, 2007 at 9:28 am
x,
Sigh. I knew somebody would say that. That is why I have the footnote saying I am talking about *debugging* not *using a debugger*. Cedric’s post is about the latter. Nowhere in my post did I say you should use your debugger less.