Might be stirring the pot here.
It seems like the first statement of DHH’s post sums up his thought’s rather well:
Test-first fundamentalism is like abstinence-only sex ed: An unrealistic, ineffective morality campaign for self-loathing and shaming.
Test-first is definitely NOT the only way to produce fantastic code. Also, anyone who doesn’t test first is NOT a bad person who should feel bad.
The biggest problem, which the whole first half of his post is dedicated to, is there are many in our community who enjoy making people feel terrible for not testing. There’s a certain self righteousness some show when talking about how “code isn’t real code unless it’s tested”. It’s evident in almost every talk on testing, they all start with “how many of you write tests?”, “how many of you have 75% coverage”, etc. These talks then go on to tell you how great testing is and everything you code you should test first without exception!
So I think the first point is that as a community, the test first dogma is very unforgiving and that’s intimidating. It’s certainly something I wasn’t comfortable getting into.
The second point is DHH definitely isn’t saying we shouldn’t test our code. Tests are fantastic and give us the confidence to continue evolving our systems without destroying the foundations. He’s simply tired of writing unit tests for everything, mocking out all the interactions for the sake of faster tests. He wants to move rails more towards acceptance testing as speed isn’t as much of a concern.
By the way it seems this isn’t stark contrast to the views expressed by thoughtbot or Sandi Metz. Sandi says “The true purpose of testing is to reduce cost”. There is a lot of class methods defined as private, and as such shouldn’t be tested as you should only test your objects public methods.
I’ve been enjoying TDD since I’ve started employing it in my own projects. However, I’d be a lier if I said it was all rainbows and sunshine. Acceptance tests and integration tests have been the most successful while I struggle to justify unit testing my router and controllers.
By the way Sandi also always gives a rule and then a list of situations in which you should break it. Saying that TDD is the only option seems short sighted and in the end my cost more then it’s worth. I think that’s the point DHH is trying to convey is that unit testing every single line of code is too much.
We should aim to write the best code we can, for the lowest cost.
Testing helps us achieve that.
Being religious does not.