From: David Masover Date: 2008-08-21T12:23:53+09:00 Subject: Re: BDD and TDD - What are they for? On Wednesday 20 August 2008 21:46:25 Phlip wrote: > Right. The bigger the project, the longer it runs, the more you need tests. Well, more than that, my point was that the longer you wait, the harder it's going to be to write those tests. Doing tests early on forces you to make things testable. It forces you to break your program down into somewhat-isolated units. I had a graphic example of this -- I was downloading an HTML document from a site (with Open-URI) and then parsing it (with Hpricot). How do I test that? I suppose I could leave it as-is, but then I'm assuming the site in question is always up. I'm not testing the site, I'm testing my code. So the solution was to refactor -- split the parsing from the downloading, and provide a convenience wrapper that does both. But you see -- refactoring is exactly what testing is supposed to make easier. Wait too long, and you have a catch 22 -- you have to refactor to test effectively, but you need tests to refactor effectively. So either way you go, you're going to be somewhat ineffective. And the longer you wait, the worse it's going to get.