| I've also never found TDD to really be very beneficial except for all but the most trivial utility libraries. Most of the time, I have an idea of where I want to go, but not necessarily exactly what my interface will look like. Writing tests beforehand seems to never work our since nearly always, then will be some requirement or change that I decide to make that'd necessitate re-writing the test anyway, so why write it to begin with? The extent of my tests beforehand these days (if I write any before code) are generally in the form of (in jasmine.js terms) it('should behave this particular way', function() {
fail();
}); Basically serving as a glorified checklist of thoughts I had beforehand, but that's no more beneficial to me than just whiteboarding it or a piece of paper. That said, all of my projects eventually contain unit tests and if necessary integration tests, I just never try to write them beforehand. |
Put "test stubs" out there that define what I'm testing in "human" terms, leave the stub either skipped or failing.
I've also found that if I wait a day or 2 after writing the implementation to write the tests, they catch much more.
If you write the code to match the tests, or you write the tests right after the code the chance that both the test and the code are wrong is much higher in my experience than if you wait a bit and come back to write the tests with fresh eyes.