bitwix

Tangential comments about Software Development

Friday, June 27, 2014

TDD is a lifestyle choice

I watched the #IsTDDDead videos  and felt better about myself. Much though I admire Kent Beck, I just can't live up to his standards. I cannot do TDD as an everyday practice.

"Can you write a right-hand menu which slides all the page to the right when it reveals itself" Yes, I can but I can't write a test to check that it works. Maybe I could if I tried really hard, but would I trust my test assertion that the left-margin was now -100px? Would I trust that my test passing meant that it worked on an iPad? No I wouldn't.

There's much agreement in the videos, because Kent, Martin and David are all wise and pragmatic. They understand the trade-offs. So no-one was a zealot. "Use it when it works for you" is the position.

And it works for me when the challenge is new and involves data processing without a UI. Next month, www.debtograph.com will offer you statistics at 30, 60 and 90 days in the past. All of the development of the number-crunching will be written using tests. Admittedly the asserts tend to be simplistic:

first pass : this.areNotIdentical( 0, sut.calcAnswer() ) ... to show that calcAnswer gets a value at all
second pass : this.isTrue( sut.calcAnswer() > 1000 ) ... as I check the calculation
third pass : this.areIdentical( 1234.56, sut.calcAnswer() ) ... once it becomes a regression test

Thanks to http://tsunit.codeplex.com/ for a test class syntax I can remember, and for code that's small enough for me to have the confidence to add to it.