Originally posted by Pradeep Bhat:
Stefan,
Isn't that how usually how we do the testing?
Is there cases where we do write test cases after coding. If yes, why and when is it done.
Thanks for your help.
Hi Pradeep,
The "traditional" way of coding is to get requirements, write the code, then remember that we have no test plans written for the code, write test plans, run integration and system tests. Any unit tests are done 'on-the-fly', i.e. whatever the programmer can think of as he writes the code - if any unit tests are done at all.
The drawback to this method is that unit tests may be skipped, the programmer is testing
after he has written the code - so may subconsciously pick only tests that will pass the code he has written, the unit tests carried out are not documented anywhere.
Test Driven Development forces the programmer to write unit tests for his code
before he writes any code. This forces the programmer to think of appropriate tests / failure conditions before he has any code / way of proceeding embedded in his brain. The code he writes for the test provides documentation for his unit test, as well as a means to exactly reproduce the test. Since the programmer must think about unit tests before writing the programs, he is less likely to skip tests, especially as he builds up his code by testing for small things and then adding to the code to make these things work.
HTH,
Fintan