“I know I should write some tests, but I can’t afford the time. I have to get this feature out the door.” That’s absolute crap, friends, and if you hear someone say it you should slap them. Yes, tests provide a measure of code reliability at the apparent cost of extra work.
But ‘tests’ and Test-Driven Development (TDD) are not the same animal. TDD (or Behavior-Driven Development – BDD) is a process that will deliver not just superior code, but massive accrued time savings over the life of your project. With experience, it will also provide immediate time savings in almost every case: when you’re doing it right, it’s usually faster to write the tests and the code than just the code. I’ll explain the difference, and walk through some concrete examples.