Wednesday, 10 December 2008

Unit Testing with CppUnit

For the past few days I've been reading the code for Polyworld and figuring out where to make my code additions. Today, I'm at a stage where I know where to make my code additions but I'd like to have a unit testing framework in place.

I reread Exploring the C++ Unit Testing Framework Jungle by Noel Llopis who suggested the following frameworks:
  • CppUnit
  • Boost.Test
  • CppUnitLite
  • CxxTest
I've used CppUnitLite and CxxTest previously but it's been a while and I've forgotten how to use them. I decided not to use CxxTest because I don't want to use Perl for the moment. I decided not to CppUnitLite because I don't want to work on extending the framework for the moment. I decided not to use Boost.Test because I don't want to use Boost for the moment.

That left me with CppUnit

As I was looking around, I also had a look at:
I downloaded and installed CppUnit 1.12.1 from sourceforge and had a look at the documentation. Things were a bit scary so I had a look around for some tutorials and found these:
Müller's example program did not work so I tried Hosken's example program which also did not work. I then removed CppUnit and installed an Ubuntu CppUnit package. Once I did that, both Müller's and Hosken's example programs worked.

Here a few other links I found interesting as I was looking around:
Now all I have to do is figure out some simple ways to avoid the overhead of creating objects that I want to test.

No comments:

Post a Comment