Skip to content

Category: Testing

Getting started with CppUnit

“Puzzle” by Olga Berrios (CC BY 2.0)

Recently I had the oportunity to start implementing unit tests in a C++ project. The chosen testing framework was CppUnit, which is an port for C++ of Java’s JUnit. To be honest, CppUnit is not as popular as it used to be, specially compared with its more handsome and stilysh cousin JUnit (at least JUnit seems to have a website written after 2005).

The main issue is that documentation comes from fairly old articles, and it is not as accesible and up-to-date as with other projects. Taking into account that modern alternatives exists, such as googletest, one could be tempted to run away and never look back. However, let’s not be afraid and try to come up with a working example of CppUnit.