Note: This document is work-in-progress. Please don’t publish it on news sites, or otherwise link to it in public without the author’s permission. Private linking is acceptable.
You should write automated tests such as unit tests, integration tests, system tests, that will run automatically on the code and yield an answer if all of them are successful, or if any of them fail.
There are many good practices for automated testing such as having daily builds or reaching a 100% test coverage. Here are some resources to get you started:
The Perl Quality Assurance project, also see their wiki.
Why are automated tests important? For several important reasons:
They provide a certain kind of executable and machine and human-understandable specification for the program, for new features and for bug reports. By writing a test such as add(5,6) == 11
both humans and machines can tell that that’s what the “add()” function is supposed to do.
A test suite with a good test coverage can better ascertain that doing refactoring, adding new features, removing them, or fixing bugs, won’t break anything.
When the program breaks, then, without automated tests, one cannot easily determine what exactly is wrong there. On the other hand if you have a lot of tests, with good coverage, you can see which tests fail, and what exactly went wrong.
In short, writing automated tests gives more confidence in the code and in changing it.
Note that having automated tests is not a substitute for having dedicated software testers (and vice versa). By all means, they are both necessary for any serious operation.