Test The Units

Test The Units

While C and C++ are both great systems languages, they are limited in their ability to self-verify. Spend some time with Ruby or some other high level language, and you'll see what I mean. Even if this were not true, though, a significant number of bugs introduced during development are lapses in logic, corner cases, or unconsidered conditions. Luckily, unit testing is a method of preventing all of these things. Once you start unit testing, you realize that it also drives more modular and intuitive system design.

When I started unit testing C, it was a rare idea. I was lucky enough to work with a couple really talented people from Atomic Object. They had a pair of rough little frameworks called Unity and CMock. These tools were works in progress and just barely usable when we started working with them... but it didn't take long to see the potential. As our testing skills improved, so did the tools... I became an active contributor to both projects, and then the primary developer.

Since that time, thousands of people have downloaded these projects. Dozens have contributed additions, fixes, and features to them. The frameworks have been featured in a couple books, one written by myself and the other published by Pragmatic Programmers.

Most recently, I have launched an online class with a colleague to teach how to use Test Driven Development to drive Embedded C projects. This class covers the open source tools I maintain, as well as general advice and process.