Michael Feathers has an article about Unit Testing that’s going around. The gist is:
“All of these techniques have been shown to increase quality. And, if we look closely we can see why: all of them force us to reflect on our code.”
I’m feeling that very directly right now. A client project I’m working on doesn’t have any tests, other than the skeletons Rails creates, which don’t run cleanly anymore. So we’re running without tests, which I haven’t done in a long time on any kind of serious project.
What I’ve discovered is that I make a lot more stupid mistakes that I never would have made with a decent test suite. It’s not that the tests would catch the mistakes. I never would have made them to begin with. From really questionable naming choices to silly little thinkos, I keep going back to revisit things and I say to myself, “Wow, what were you thinking?”
I wasn’t. Not as much as usual, since I didn’t stop and think about the test first.
What do you do when you come on a large project with no test suite, and no budget for retroactively creating one?
My contract includes the following:
I don’t think you have to come in and write a FULL test suit immediately… but as I work on the code-basee I definitely expect to spend the time to add tests for new features and existing features I touch.
if the client isn’t wiling to pay for that then I would steer clear of the project.
Good tests make a project a pleasure to hack on. No tests make it a nightmare.
I need to start using that clause Josh. IRT the ””What do you do when you come on a large project with no test suite, and no budget for retroactively creating one?”, I’m more and more getting to the point where the answer is “rrrrrrrrrun awaaaaaaaaaaaay”.
I’m actually of a differing opinion. Having come into projects with and without tests, I can find no difference in the existence of bugs between the two. Quality is always based on the programmer, not on their test suite.
I swear we’ve forgotten that with good and careful and abstracted code… testing isn’t needed.
Whenever I write something and I think “man, I should really test this!”... I immediately re-write that entire section so that it is so simple it doesn’t require testing.