Test First Methodology
Agile software methodologies, for example Test Driven Development (TDD) and eXtreme Programming, place extra emphasis on unit testing. In fact, these methodologies use unit testing to drive the development process. They advocate a “test first” approach to software development. On this approach, the developer designs and writes the unit tests for a code module before writing a single line of the code module. The developer then creates the code module with the goal of passing the unit test.
Advocates of Test First methodologies claim the following benefits for the approach:
It forces the developer to decide on the correct inputs and outputs for a code module well before developing any of the module.
It focuses the mind of the developer while creating the code module. The developer focuses on the concrete goal of passing the unit tests while creating the module.
It prevents unit testing from becoming an afterthought. If the unit tests are created first, unit testing cannot be neglected until the end of the project.
It ensures a very high degree of test coverage for the code.
Proponents of test first development often advocate executing, not merely creating, the unit tests before the code module. Of course, the tests should fail at this point. They might not even compile.