The previous chapters, Chapter 1, Getting Familiar with TDD and Chapter 2, Refactoring – Roll the Dice, gave us an overview of TDD, refactoring, and code smells from 1000 feet. It's time to take a closer look.
Now we know that the automated unit tests are a safety net for refactoring. Unit tests are re-run with every code change; failing tests indicate that something went wrong. So, the code is monitored continuously.
In this chapter we will apply Test-Driven Development (TDD) to write testfirst code.
We write tests for anything that can break basically into an algorithm or a logic, for example, the logic of calculating service tax. But we don't write tests for obvious things that can't go ...