How to make sure you write more tests

I’ve been writing way more tests for my code lately, and they’ve become the backbone of my development style.

I used to write some web code, then play around with it in the browser and look for something to blow up. Automated testing was usually an afterthought or used for confirmation. Or maybe in some cases I would write tests dilligently at the beginning of a project, but start skipping them as deadlines approached. Following TDD has always felt like sticking to high-school abstinence pledges. I wrote tests because I thought I should do it, not because I wanted to do it.

But now I’ve found a way to make writing tests central to getting my work done. It’s because of the computer I’m using now. It is such a crappy box that it takes about 5 minutes for firefox to start up. Then each page load takes about another 30 seconds at least. In the time it takes to click through three or four pages using firefox or epiphany, my twill scripts can run through about a hundred pages.

There’s a scene in Star Wars: a New Hope where Obiwan trains Luke to use the light saber while blindfolded. Well, he’s not blindfolded, really, he’s wearing a helmet with the blast shield down, but the idea is the same. Luke has to use “the force” to feel out where the floating droid is, rather than relying on his vision.

Anyway, writing web pages with this Compaq Presario 1200 feels kind of like that. It’s too frustrating to check my pages with Firefox. The only way I can make sure that anything really works is to write a test for it.

PS: I wrote this posting with lynx.

Published by

matt

My name is Matt Wilson. I make websites for Kiwee to pay the bills. I live in Cleveland Heights, Ohio, with my wife and son.

  • Phil

    “Following TDD has always felt like sticking to high-school abstinence pledges.”

    LOL. So funny. So true.

    Hope all is well.

  • http://tplus1.com matt

    Hi Phil! I just noticed that google is posting paternity test ads with this story. Time for a story on paternity-test-driven-development.

  • http://www.just-another.net Ben

    Do you think they unit test paternity tests? Or maybe they just mock it up with a mirrored environment…. Seriously, how do you test a test like that? Do they have a CPAN, with things like Test::Tester?!