TDD - A question about the approach

Posted by k25 on Programmers See other posts from Programmers or by k25
Published on 2011-01-13T00:40:44Z Indexed on 2011/01/13 0:58 UTC
Read the original article Hit count: 584

Filed under:
|

I have a question about TDD. I have always seen the recommendation that we should first write unit tests and then start writing code. But I feel that going the other way is much more comfortable (for me) - write code and then the unit tests, because I feel we have much more clarity after we have written the actual code. If I write the code and then the tests, I may have to change my code a little bit to make it testable, even if I concentrate much on creating a testable design. On the other hand, if I write the tests and then the code, the tests will change pretty frequently as and when the code shapes up. My questions are:

1) As I see a lot of recommendations to start writing tests and then move on to coding, what are the disadvantages if I do it the other way - write code and then the unit tests?

2) Could you please point me to some links that discuss about this or recommend some books (TDD)?

© Programmers or respective owner

Related posts about c#

Related posts about TDD