The Latest DHH Debate… Too Much Testing?
So the latest kerfuffle in the Rails world is DHH’s recent post, Testing like the TSA. In here he has a few non-controversial things to say about testing, and over-testing. IE:
But while all that nuance might have a place in a two-hour dinner conversation with enlightened participants, not so much in a blog post. So let me firebomb the debate with the following list of nuance-less opinions about testing your typical Rails application[...]
I had a great conversation with Dan here at my local Ruby on Rails group about this and while we didn’t see eye to eye, I think we came to the agreement that people are kinda crazy. On one hand, if you cargo cult all about testing you’ll end up with 30,000 lines of tests for 10 lines of code, or worse, fall into the trap of “ok, time to write my blog in 15 minutes… oh, I should test, what test framework, hmm… maybe I need to write my own, ok, lets start that, oh, how about a new DSL to support it, that’ll make it easier….” Case in point The Perfect Apostrophe cira 2006 from Merlin Mann. Or you go to rails looking to write a quick blog project and find that you have to learn RSPEC, Cucumber, Capistrano, WebRat, and 5 other new tools before you can even start writing your blog.
Of course as Dan said, if you come to just write code you’ll just write code, but honestly I think there are a lot of programmers in an influenceable stage and they come to Rails wanting to do the right thing and see the obsession with testing and maybe get sucked into, as DHH puts it, “fondling balls and confiscating nail clippers” instead of actually writing the code and creating the cool things they’re here to enjoy.
Obviously DHH has a lot of influence in the community, and there is danger of newbies seeing his post and saying “oh, well DHH said not to test so I’m not going to” (note: he never says don’t test). I think there might be more danger in scaring new members of the community away telling them (in a strong German accent of course) No you may not write ze code, YOU MUST TEST AND YOU MUST TEST ALLLLL ZEE TIME!
As always, this write endorses a middle ground, somewhere in between the extremes.
Potentially completely relevant is Google’s stance on test coverage.