Here’s an essay I wrote several years ago but apparently never posted. It didn’t get where I wanted it to go, and turned into a bit of a rant. Hope you enjoy it as much as I still do.
Test first development isn’t testing. It’s development. It’s prep work for a developer. It doesn’t test anything. And as a matter of fact, if you could write tests first that work without testing before running them, you’re probably a perfect coder, and writing tests would be superfluous.
Now, running a test after the code is written is testing, but in the simplest possible sense. In about the same way that spell-checking is editing. Or rather, you could consider the spell checker the compiler, and the notoriously bad grammar checker equivalent to the also notoriously bad warnings a compiler gives. But no one considers a document even “proof-read” because Microsoft Word didn’t underline anything. Actually, a document of any length –say half a page or more– is probably unreadable if there are no squiggly underlines in it.
What would be your own unit tests (or even automated functional tests) that could be done to a document? Pretty difficult to come up with something useful, isn’t it?
But code is structured, you complain? Stop complaining, so is English. As a matter of fact, supposedly your code is just a much longer description of a specification written in English (or Swahili). It’s longer because computers aren’t as smart as people, and because of that, you have to talk down to them and use lots of little words and a lot more punctuation.
Let me help you out. There are some things that can be automated. Such as word count. Formatting guidelines. Header style. Beginning, middle, and end. You could come up with run-on sentence algorithms or text analysis. But the real trick is turning a document into an executable, because that’s what code does.
How are documents executed? By modifying them. The aforementioned word count can make sure the document length doesn’t change — or if it does, that the changes occur in an expected area. Or that formatting changes (margins, fonts, etc.) are changed across the board.
Fairly useless stuff, right? But that’s all automated tests can do for software. Granted, there are a lot of variables in software that aren’t in documents, and code changes happen even more. So there is value in REGRESSION tests being automated. Because a code change is like a document edit. You don’t want to edit one paragraph and expect the format (or word count) of another paragraph to change.
Now, I’m not arguing against automated testing (it’s what I do for a living), but I’m arguing in favor of knowing what it can do, so it can do it well. The biggest travesty in quality assurance is the so called “test first” methodology. It’s really just a cop out that says you’re not going to test.
Supposedly, the idea is to do the things first that you never have time to finish. You know, like washing the dishes. By the time you’ve fixed dinner and eaten it, it’s time for your favorite television show (or online chat game, for you WoWers), and there just isn’t time to do the dishes.
Here’s a novel idea — why not do them before cooking? Cooking is what takes up all the time, and the cutting and mixing and associated tasks. Cooking is Very Important. After all, without the cooks, there’d be nothing to eat. Therefore, of course, cooks are the most important people in the cooking process, right? As such, they don’t have time to do the dishes, so you need to find someone else (less important) to do them. And do them before you start cooking. Makes sense, right?
Okay, you could test (I mean wash dishes) while cooking. Every time a cook dirties a dish, a tester (I mean dishwasher) could wash it. Then, everyone could sit down to dinner and all the dishes would be done, and no one would miss Wipeout (or another quest to chop wood or fight squirrels).
Except of course the dishwasher, who’d also miss dinner. Because while a spoon can get washed after every use, that big pot of goulash can’t get cleaned until after everyone has been served (and served seconds, if the cook is any good.)
And of course, there’s the little problem the cook never thought about of all the dinner plates, silverware, and glasses. Those need washed too. If only they could be washed first, or iteratively.