Wednesday, March 7, 2007

TDD is meant to be declarative programming

I've seen a lot of people practicing TDD (Test Driven Development) over the last five years and I see some (not all, not most) bad results. What do I mean by a bad result?
  • Too tightly coupled to the implementation (some classic examples including abuse of mock objects).
  • Unmaintainable.
  • Unintelligible (especially if your using 5 mock objects at once - just don't go there).
I think the common misconception people have with TDD is that they think they should be testing the implementation when they write tests.

The great thing about TDD is that you can be declarative in your tests, specifying the outcomes (dare I say behaviours?) that should occur for specific scenarios. With this shift in emphasis the tests you write will be less brittle (more agile?).

A good test should stand the test of time.

No comments: