C++ Unit Testing Frameworks

I like to keep an eye on various build and testing tools, for potential integration with Pulse. As such, I’ve started to amass some links to unit testing tools/resources for C++, where there are many competing options:

  • Exploring the C++ Unit Testing Framework Jungle: the most comprehensive article I’ve found on the topic, even though it is getting old.
  • CppUnit: probably the best know xUnit port, supported in Pulse already. Does a decent job.
  • Boost.Test: part of the well known set of Boost libraries. Naturally has dependencies on Boost.
  • CppUnitLite: a minimalistic rewrite of CppUnit, intended to be simpler and more portable. May be appropriate if you don’t mind getting your hands dirty to add the features you need.
  • Nano Cpp Unit: more an exercise in illustrating the barest testing framework than a usable framework itself.
  • Unit++: pitched as a more “C++ like” xUnit port. Documentation is thin on the ground, and I don’t have any practical experience with it.
  • CxxTest: takes the novel approach of using Perl to generate a test runner, simplifying the code. Also relatively portable, although of course you will need Perl.
  • TUT: a simple, template-based framework distributed as a single header file. Reasonable portablility (given a modern compiler). Lacking some features of other frameworks, but without any dependencies.
  • cutee: another framework aimed at simplicity. Looks to have test case creation down to its simplest form. Documentation is thin.
  • CppTest: you guessed it: another framework aimed to be simple and portable. Supports a few output formats out of the box, including HTML reports.
  • UnitTest++: co-authored by the author of the article above, this framework hopes to combine the best ideas from others. Documentation is non-existant, but on the plus side it is one of the more modern frameworks (developed this year, not 2004!).
  • QtUnit: probably a good option if you were using Qt, but is officially unmaintained. Mind you, most of the other frameworks are also dormant.

That’s all I have gathered so far. I have to say, there are a lot of players out there, but little action. A few interesting ideas, but no framework seems to be a clear leader. I hope to get some time to play in depth a bit more, in which case I will flesh out more details.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • DZone
  • Ma.gnolia
  • Reddit
  • Simpy
  • Slashdot
  • StumbleUpon
  • Technorati

6 Responses to “C++ Unit Testing Frameworks”

  1. martinus Says:

    We have been using CxxTest for some time, and are quite happy with it. We integrated the unit tests in a post-build event in Visual Studio. This has the advantage that the test console output is directly written into the visual studio’s compile window, and when using the right logger formatter you can doubleclick on the error message to jump directly to the problematic assert code.

  2. Jason Says:

    Indeed, output formats are key for tool integration. Suprisingly, few frameworks seem to support an easily processed output format (e.g. XML reports) out of the box. These are great for reading results into other tools, or rendering as HTML.

  3. DJW Says:

    Indeed, what did happen with most of the frameworks’ development during 2004?

  4. Gail Nagle Says:

    I would really like to know how you got any output from the post-build event to show up in the output window (i.e. the compile window in VS). I get no output there even though when run in a cmd shell the test executable runs fine. This is true whether or not a test passes or fails. I am using the ParenPrinter output formatter. Also, I am using VS.NET 2003. Thanks for any help you can provide.

  5. Gail Nagle Says:

    Follow-on to my last post – the culprit is Qt not cxxtest. If Qt is linked in, no output ever goes to the build window when running from a post-build event. But there is a neat addition to cxxtest OutputDebugStringPrinter.h that can be downloaded from http://sourceforge.net/tracker/index.php?func=detail&aid=1161786&group_id=52834&atid=468189. This is not as nice as the post build event since it requires that the test be run by Debug->Start or triangular icon in the tool bar, but the test output will now go to the Build window. And you can double click an error and it will go right to the correct line in the test file.

  6. Steven Says:

    A rather new, yet interesting tool is cfix (http://cfix.sourceforge.net/) — it is for Windows only, but allows tests to be written in a very clean manner… I tend to find it a lot more convenient to use than, for example, CppUnit.

    -Steven

Leave a Reply