Unit tests are good

November 10, 2007

Some developers can write code from start to finish and and end up with a complete and useful solution. I used to think I was one of those developers. Now I don’t think so much of myself. I tend to write some code that’s good enough for the moment, and build on top of it like a stack of cards which at some point starts to collapse under its own weight. In the past, this is the point at which I lose interest in the project and usually banish it to the code archive.

Lately I’ve had some spare time to spend on the game project I have worked on in the past year. After spending some time away from the code, I felt the need to refactor the code. The game-specific code was tied in with the engine code enough that it became somewhat of an overwhelming jumble. So I decided to attempt a clean break from the engine and the game code.

While I am doing this, I am spending the time to do unit testing. While I wrote some tests for the base display, input, and sound objects on the first pass, I didn’t attempt to write a thorough unit test, which stressed all of the features of a particular module. Is this a waste of time? I’m not sure, but it’s a different approach than I’ve taken in the past, and in the past, my code has tended to wither away and disappear after becoming stale. I hope to keep this code around and launch a few more projects based on this engine so for ow I’ll continue to work on it.

Leave a Reply