You are here

Automated testing in Perl

Topics: 
Perl

Testing ! Is there anything sexier than program testing ? Apart from 3D gaming development, cloud computing, automated Kickstart installation, high-performance clustering, Rails development, etc ? Okay, testing is even more boring than writing documentation, but fact is that we, humans, don't like testing, but computers love this type of bandwork. And testing is necessary : adding little changes to other people's programs, break them in the most horrible ways.

I've learnt this the hard way.

A serious bug in one of our backup clients forced me to upgrade the package. No problem, just dropping the new binary in the package, relabel everything, and build the thing. Not a good idea for a package that wasn't released for over 18 months, and passed through 4 different responsible teams. The postinstall was a 300 line spaghetti mess, which in the end I ended up rewriting half of it. And still more and more bugs kept popping up, which left me terribly ashamed.
I needed a way to test automatically all of the outputs of the postinstall, and at the same time to check if all configuration files were created correctly, and if the program was able to connect automagically to the backup server.

So I decided to have a look at Test::More, and delve into the documentation, and try to write some test scripts myself. Boy, was I pleasantly surprised (as allways with Perl, but this aside) ! Within one hour, I had a test written which checked all of this stuff automatically, and even discovered 4 more bugs in the output. Needless to say that since now, I'm addicted to testing my programs.