Experienced agilists talk about becoming “test infected.” For everyone, unit testing starts out as a chore that seems like it’s more work than it’s worth, but then you get over a certain hump and suddenly unit testing is a breeze. The benefits become manifold and profound, and you begin to wonder how you ever programmed without it.
One important milestone on the way to achieving test-infected enlightenment is the transition from test-after to test-first. All developers start out writing the production code first and then write unit tests around it. It’s the only way we learn. But, eventually, we begin to see the power of writing the tests first. This used to be called Test-Driven Development, but it’s more accurately referred to as just Test-First Development (although we still abbreviate it as TDD).
For me, the greatest thing about TDD is that it gets the subjective part of the problem out of the way early, leaving just the objective part to puzzle out. “Okay, now that we know what we need to accomplish, we just have to get it to work.” It’s a rather liberating feeling. Continue reading Test-First Development Can Be Liberating