TDD Worst Practice: Test Driven Debugging

time to read 1 min | 190 words

I saw this trend at a few of my clients. The use of NUnit tests not as a way to drive the design or verify that the code works, but as a cheap way to setup the code into the conditions that they needed, and then debug through the code, to verify that it works. This is often used in the beginning of the project, where there isn't enough UI to drive the functionality of the code.

I tend to do the same when I try things, or want to verify something, so broadly, I don't have an issue with this approach to solve issues. TDD urge you to build tests before you fix bugs, but this isn't it. And I can certainly understand the need to explore code that doesn't have any UI, but these tests violate just about every rule of TDD that they can (not repeatable, not meaningful, highly order dependant, data dependent, etc).The bad part here is that those teams check the tests into the source repository, and some of them thinks about them as a real tests.