News for hackers. Stuff that matters.
Re:Why I don’t use TDD or BDD by steveklabnik on Saturday September 04, 2010 @05:32PM (#1663431)
The entire point of writing software is to automate processes that can be done manually, but are too time-consuming and/or hard to do so. Testing is a great example: yes, I could run through my entire application and hand-test it every time I make a change, or I could automate the process and save myself a ton of time and work.

Viewpoints like these are the reason we have a long way to go before software is truly reliable.

Re:Why I don’t use TDD or BDD by kenjackson on Saturday September 04, 2010 @05:50PM (#1663472)
The issue isn't about testing, it's about unit testing. And really more specifically about BDD/TDD.

And I must admit that I've struggled with TDD myself. And I've generally hit a couple of issues:

1) Bug rates in test code for some reason seem to be higher than that in production code. Not sure why. But the end result is a LOT more test bugs than product bugs. I've sat in meetings where people wanted to block shipping the product because of test bugs. No evidence there were any blocking issues in production code.

2) The opportunity cost of TDD style unit tests are rather high. Given the choice I think I'd rather a more in-depth design and code review.

While I think unit tests are valuable, I take a more sparse notion of them. Based on code review and design, unit test the code that you have worries about. Where you think there's a greater chance of a seemingly innocuous change breaking the code.

I've seen little value, in the projects I've been a part of, with the BDD/TDD approach. It does seem like a lot of busy work and not a lot thought put into where the value is. And there's actually pretty good industry data (and I suspect open source data as well) that its actually not hard to determine what parts of a program are going to be the buggiest in production. I'd really love to see a test approach that is density driven...

But with that said, if you're writing a 20,000 line web app, TDD/BDD is probably fine. You can generally kick out the code and get full test coverage in very short order.

Re:Why I don’t use TDD or BDD by steveklabnik on Saturday September 04, 2010 @06:01PM (#1663487)
One caveat: I come from the Ruby world, which has top-notch testing support. So maybe it's horrible in other-platform-land.

I think that it is slow going, at first. Testing is a different skill than regular coding, and at first it goes slow. But now, I spend much less time writing tests because I already know how to properly write them.

It's hard to properly evaluate the amount of time tests save you because it's an up-front investment. But I can't count the number of times I've wanted to change something fairly large in my codebase, and did so fearlessly, because then all my tests broke and I was able to quickly fix things where they were broken. In one recent project I decided to completely re-do the authentication system, and it only took me about an hour, because I already had an exact list of every place that needed attention, due to having great test coverage.

> It does seem like a lot of busy work and not a lot thought put into where the value is.

I see it the other way: if code has to be written, it should also be tested. If it's valuable enough to have spend the time to implement, it's worth making sure that it works correctly.

Re:Why I don’t use TDD or BDD by kenjackson on Saturday September 04, 2010 @06:12PM (#1663510)
"But I can't count the number of times I've wanted to change something fairly large in my codebase, and did so fearlessly, because then all my tests broke and I was able to quickly fix things where they were broken "

To me that is a bit scary. Tests don't prove the absence of bugs. They can only prove the presence of them.

I never make big changes, even in the most tested pieces of code that have unit, integration, UI, and manual testing without some trepidation. Because the fact of the matter is that these code paths get the reputation they get because a customer comes back and says this doesn't work and we're like, "oh... that's how you use it?"

"I see it the other way: if code has to be written, it should also be tested. If it's valuable enough to have spend the time to implement, it's worth making sure that it works correctly."

I don't disagree. It should be tested. I think our disagreement is if TDD/BDD style unit testing is the best way to do so.

Re:Why I don’t use TDD or BDD by steveklabnik on Saturday September 04, 2010 @06:22PM (#1663534)
> Tests don't prove the absence of bugs. They can only prove the presence of them.

Absolutely, and having a list of where they were (now) present was a real productivity boon.

It's true, I think we're arguing over something very small. I don't think automated testing is the end-all be-all. But I do think it's much much better than not doing it.

Re:Why I don’t use TDD or BDD by kenjackson on Saturday September 04, 2010 @06:28PM (#1663548)
I do want to be clear. That I'm not arguing against "automated testing". It's really against a style of unit test development that is all the rage: TDD/BDD. The devs I've worked who practice it, is through the use something like Cucumber to drive the development of the application with tons of unit tests.

I'm a huge advocate of automated testing. And again, just in my experience, the productivity and perceived code quality I saw coming out of the BDD/TDD side of the house didn't seem to be a step in the right direction.