Test driven development is made famous by UP or Agile development model. Wherein the Developer first writes the unit test case and then writes the class. Often this unit test cases are included in the build process. Ant has task for including the unit test case as part of the build process.
For ex..
You can configure the ant in such a way that if any of the unit test fails,break the build.
Some of the advantages of test first approach is
Provable Verification: Sometimes after you write class and methods you wonder whether it really works in test environment with real values or is it just your gut feeling(it should work!!). In such cases if the project is very big and have lots of dependencies it becomes really tough to build, besides there is lot of hardship building test beds, get the hardware ready etc.But unit test cases such as Junit provides instant gratification of knowing whether class works as written or not.
Easy to change things around: Its easy to change code without worrying too much about whether this will break the dependencies or whether change is right or not. One of the drawbacks with unit testing is that sometimes developer forgets to update the unit test case when new feature or new fix is checked into the code base. This may result in false security of build is okay since unit test cases passes also it may lead to some unit test failing inadvertently, causing lot of frustration among developers who may not have done this change.
Advocates of agile development methodology prescribe that whenever new issue or enhancement comes for existing code base, first unit test case needs to be added and make sure the unit test case fails, now the change is made in the corresponding, class method,or interface in such a way that unit test case passes during the build. Once Build is successful, the updated fix can be delivered to QA for further sanity, later delivered to customer. This kind of test first or write unit test first approach eliminates much of issues arising out of regression.
This is how the flow chart goes for a customer issue.













