The Primary Benefit of TDD

With plain ol’ after-the-fact unit testing, the obvious, most significant benefit you gain is increased confidence that the code you write works as expected. With TDD, you gain that same benefit and more!

Systems degrade largely because we don’t strive often or hard enough to keep the code clean. We’re good at quickly adding code into our systems, but on the first pass, it’s more often not-so-great code than good code. We don’t spend a lot of effort cleaning up that initially bad code for many reasons. Pat chimes in with his list:

  • “We just have to move on to the next task. We don’t have time to gild the code.”

  • “I think the code reads just fine the way it is. I wrote it, I understand it. I can add some comments to the ...

Get Pragmatic Unit Testing in Java 8 with JUnit 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.