(BTW: Does anyone have any knowledge of the C++ testing frameworks listed here at the bottom of the page? Got any favorite?)
One of the things I'm doing right now in Magen is helping a company that uses hard core C++ for various networking and conferencing software move to a more agile oriented development regime. As part of that they are learning Test Driven Development - in C++. There are a few things I can say about this. Mainly that it's a struggle all the way through.
The fact is that I've never been a C++ wonk and so I'm having some difficulty adjusting to the way things are done in in this language. Add to that that:
- CPPUnit is the framework of choice for C++ (at least that I know of).
- There are no refactoring tools for C++
- Visual C++ 6.0 is horrendous to work with. Lack of usability is apparent in everything.
Some of the early conclusions so far:
- Creating unit tests in C++ is done by inheritance (no attributes to speak of) and by using special macros to manually add your test cases and test fixtures into the unit test runner
- The only way we could figure out so far on how to run the unit tests is by manually using the test runner objects from within the main method (which means we are bound to using a console application)
- Documentation on how to make a project that uses the GUI test runner is practically non-existent. Only a small sample comes with CPPUnit and it's hard to decipher.
- It pretty much works the same way like NUnit but you have much less
- types of assertions
- "attributes" for example, no such thing as testFixtureSetup or TestFixtureTearDown methods to override from the base class
- ease of use - at least 4 steps needed to create a new unit test
So overall this leads to some facts:
- If its harder to write tests in C++, less people are likely to do it.
- If it's harder to refactor code, less people will do it (this is more an issue with the tools - VC++ 6.0)
- Agile wok in C++ is much harder but I can honestly say it does not have to be.
Sadly it doesn't look like there's any sort of agile innovation in this territory. CPPUnit is not getting any new features soon, and something like the NUnit-Addin in C++ is nothing but a dream. That sucks because there is a lot of code out there being written in C++. Has this suddenly become some sort of "second class" platform for agile tools? If so it could have some sort of explanation. Mainly that could be that when going agile you want as much productivity as you possibly cam and so automatically turn to RAD-oriented tools and IDEs. C++ has never been considered as such. But that could change.
If an Add-in like Visual -Assist is so smart, it could easily add refactoring features to the platform. CPPUnit and variants cold be written to more easily run form a GUI. More and better documentation and blogs could be written on these issues.
And to finish off, here's something I found on my search for a Mock object framework for C++ .
This guy tells it like it is and one could easily replace "Java" with ".Net":
After a solid year of Java at its finest, returning to C++ and no good unit test libraries (CPPUnit being about it), no mock objects, no IDEA or decent Eclipse support, no ant or maven, no good coverage tools, no good code analysis, no good dependency analysis on and on and on. Tools make the programmer. And C++ has dog food for tools compared to the wealth of open-source projects for Java. Now that I'm working on a C++ project, my development efforts are at least doubled for the same work, and I continually feel that I am leaving imporant parts of best practices out of the picture. Nor does it look like that's about to change anytime."[update: looks like people are actually looking for Agile C++ developers. I bet those are really hard to find these days]