On Thu, 20 Jun 2013 21:38:08 +0200 Jacob Carlborg <[email protected]> wrote:
> On 2013-06-20 20:14, Sean Kelly wrote: > > > And this is why the waterfall model (which TDD seems to encourage) > > tends to be problematic. > > You don't write all the test at once and then all the implementations > at once. Write tests for one function first, then implement it. Then > move to the next function. > > Also, tests are not written in stone. They should evolve and change > just as much as the rest of the code. > But then at that point, where's the benefit of writing the tests first? I can still evolve/change the tests if I wrote them after the implementation. Writing them before the implementation just means I have that much more bookkeeping *while* implementing. May as well just hold off on the tests until I have an actual interface to test against. It not like the pre-written-but-failing tests were doing me any good while I was still implementing. I'm not saying that it's necessarily bad to write a function's tests before the function itself, I just don't see what it really matters to code the tests first. The important thing is that the tests get written, ideally before you move on to something else. If you have the discipline to write the tests before the function, then you have the discipline to write the tests after the function. If the issue is to make sure the tests promptly get written promptly, then D's built-in unittests do far more to encourage that than TDD would seem to.
