The classic model to building software is, "code it first and then test to find errors". That is how most of us started software development. In fact that is the practice most developers and development companies follow. There are software companies I know which have lengthy quality assurance processes and huge teams with QA people and testers but still what they simply do is "write it first and test it second".

This type of testing keeps the developer away from testing. Normally developers don't like to consider themselves as testers. Although if the developer himself performs testing, it is less likely that he/she will exercise or discover every possible edge case. Developers are normally over confident about what they code; they blindly guess it will run without any problems. However, that is not true in almost every case. The bugs in code can pop up at any time even after years of operation in production systems. It is cheaper to find the bugs and fix them early in the project life cycle than correcting them later after you put the system into operation.

The test first development (a.k.a Test Driven Development TDD) as opposed to code first development emphasizes writing the test code before you write the actual implementation code. The tests are written for a particular piece of functionality know as a unit. (Hence they are known as unit tests). Usually this is done by the same developer who then write codes for the functionality which is under test. The developer even before running his code can first run the test to find it fails and then write enough implementation code to get the test pass. Then she goes to next step. Again writing tests for the next unit of functionality, running the test, watching it fail, and again writing enough code to make it pass. He continues this cycle until all the customer requirements get implemented. The final outcome of this process is an operational software which is fully tested and confirmed as bug free. Because the tests were written for the functionality of the system, the tests can also serve as a documentation.

Test first development got lot of attention and buzz in recent years. These days, writing code without first writing tests is generally considered as a bad practice. However it is still the most common practice.

Starting form this introduction, I will write few posts on test first development. Specially focusing how test first development is done using Ruby on Rails. Test first development can be done in most current popular development languages. I am choosing Ruby on Rails for these articles because that is the development platform I use most, and what I am most familiar with.