Looking at C++ Unit Testing Frameworks

bug.gif

I've used JUnit and the Unit Testing Framework in Xcode 4, and both are pretty nice - they allow you to write tests, not headers and a lot of boilerplate code. Just the tests. Lots of simple assertions and tests, and it's really not bad at all to use these guys. But with C++ I'm finding it a lot harder to start using a testing framework. Maybe it's me, maybe it's just the language, but it's not a lot less than writing test apps, and having explicit return codes.

I'm not saying that testing isn't useful, what I'm wondering is if C++ as a language is really set up to have a nice, simple, unit testing framework like JUnit or SenTesting Framework. After all, there's a lot of flexibility in Java and Obj-C that simply isn't in C++. You can add methods to Java and Obj-C in the implementation file and run with it. Reflection (introspection) allows the language and framework to see what's available to run, and then run it. Not so for C++.

So I'm wondering if there's really any better solution than a series of good testing apps with proper return codes, and then you just run one after the other until you have what you need. Not ideal, to be sure, and it takes some effort and discipline to make sure the test apps are done properly, but I just don't see a way to make it happen in a significantly easier way.

I'll keep looking, though. Maybe someone is going to crack this nut soon.