Kurt McKee

lessons learned in production

Hey there! This article was written in 2008.

It might not have aged well for any number of reasons, so keep that in mind when reading (or clicking outgoing links!).

Unit testing

Posted 23 February 2008 in renquist

I just committed basic unit testing support to Renquist, implemented using Python's unittest framework. The results were quite pleasing. Now I can quickly run multiple automated tests to ensure correct behavior and avoid regressions! Huzzah!

For my first two tests I decided to try using a blank file as both a Feed and as a List. The blank Feed test uncovered a bug I hadn't considered, while the blank List test made me fix a problem I had already tagged as a failure point in the comments of the source code. Both bugs are fixed now, but there's surely still a lot of code that isn't being touched by these tests. But how can I identify those untested lines of code?

The first thing I thought after writing those two test cases was, "There should be a way to visually identify the untested code." After looking through the Python documentation, the first thing I found was the "trace" module, which can output every single line that gets run. It would take almost no work at all to generate a very simple HTML file, highlighting tested code (or untested code).

Before I write that software, though, I'm going to search a little online. I can't imagine that someone else hasn't had that idea, too.

Here's to automated testing!