Unit Testing as Bug Repellant

Just like mosquito bites, many software bugs are simply annoying. However, just like some mosquitoes can transmit harmful diseases, some software bugs can cause a lot of harm. This is particularly true when using LabVIEW to control real-world hardware.

Nobody likes bugs, whether they are mosquitoes, black flies, spiders, or software bugs. One mosquito bite is generally mildly annoying but tolerable. Similarly with software, if your customers find a bug, it usually results in mild annoyance. Of course, there are exceptions to both: some mosquito bites can be deadly as can some software bugs. What really drives people nuts about mosquitos is the repeated exposure. Similarly what drives your customers nuts is when a bug you’ve previously fixed reappears.

Okay, so maybe not everyone hates bugs, but I’m pretty sure your customers are not as excited about them as this guy.

When we first realize that there are mosquitoes around (this usually happens when we first get bit), what is the first thing we do? We reach for the bug spray to keeps the bugs away. Similarly, once we encounter a software bug we can use Unit Testing to keep it from returning.

Just like bug repellent is the bent way to keep mosquitoes away, unit testing is the best way to keep repeat bugs away.

Before you fix the bug create a unit test to catch it and verify that the new unit test does in fact fail. Then fix the bug and run the unit tests to verify that you did indeed fix the bug and didn’t introduce any new ones. Now that particular bug will not come back, because if you do happen to reintroduce it again your unit tests will catch it before it ships.

Leave a Reply

Your email address will not be published. Required fields are marked *