Monday
Sep062010
Unit Testing in C++ is harder than..
Monday, September 6, 2010 at 10:45AM Unit Testing in C++ β itβs even harder than Inidian Pole Gymnastics
I mean seriously - CPPUnit is the devil. What kind of test framework do you use in C++?in
Unit Testing
Unit Testing 




Reader Comments (1)
It's a shame you lost all the comments when you migrated your blog.
However it gives me a second chance at "first post" ;-)
I mentioned in the original comments that I was working on my own C++ unit test framework (in recognition of your observation that the current state of play is not great - even to this day).
I have now made some headway on that framework and am nearly ready to publicize it more widely. It already has quite a bit of interest on the ACCU mailing list.
Introducing CATCH.
Key features are:
* Implemented all in headers - no libs to build!
* No external dependencies (just C++03)
* Simple, expressive test macros (more on that in a moment).
* Self-registering test cases (both as free functions and as methods)
* Can break into the debugger on failing line (Windows & Mac)
* Multiple reporter formats (extendible) including a Junit reporter for CI integration.
* Nestable sections for BDD style test cases.
* Powerful test data generators for arbitrary ranges (coming soon).
* Objective-C bindings
There's more but I should stop there (check out the wiki on the GitHub page for more).
Just on the "expressive test macros bit" - what I mean is you can write, for example:
REQUIRE( a == b );
Note that standard C/C++ operators are used instead of a whole set of different assertion macros. Yet if the test fails you'll get the values of a and b printed out independently!
Anyway - if this has got your interest take a look at the GitHub project:
https://github.com/philsquared/Catch