In the previous instalment, Autotools were used to create a separate library from our source code. This time I will show how to add unit tests.

Unit testing is a very important tool for every software engineer and fortunately the Autotools provide us with an easy way to create and use unit tests. After creating the tests running them is as easy as running the following command on the command line:

make check

I will continue where I left of with the Autotools setup for libraries to show how to incorporate unit tests in your project based on the CppUnit. Why not one of the more recent C++ unit test environments such as the Boost Test Library or CxxTest? Simply because I am more experienced using CppUnit and know how to set up Autotools with it. In later instalments I will add setups for other testing frameworks but these setups will probably deviate not too much from the setup using CppUnit.

It is of course assumed that the CppUnit test framework is already installed on your machine. If not then the internet provides sufficient information on how to do so. Continue Reading »