Test-Driven Development (TDD), is a software discipline in which we write an automated test case before we write any code. It is a principal practice of Extreme Programming.
The basic pattern is as follows:
The first step is to write an automated test case for the next piece of simple functionality we intend to implement. The test will fail because we haven't written any code to fulfill it yet.
The next step is to write the most straightforward code implementation to fulfill the test and make it pass.
The final step is to refactor the code so that it meets our coding and implementation standards.
When using refactoring with TDD, they make a powerful ally. The TDD test suite enables us to take the refactor step with the confidence that the behavior hasn't changed, as we make the code simpler and more in keeping with the system design.
So, if...