Follow @RoyOsherove on Twitter

Mockpp - Mock Objects for C++

Yeah, I know that what I quoted the other day about C++ is not entirely correct. You do have a mock object framework for C++. Here's a part of the documentation for Mockpp:
 

"But let me warn you

If you take the wrong macro or maybe just have a small typo you will get loads of error messages all pointing to the same line. You will have no idea where to start and search the problem. I strongly recommend to take little steps when setting up such objects: add one single method and compile. Continue only if it compiled flawlessly.

If you don't take care you will quickly find out why macros are evil and should be avoided where ever possible (unfortunately they are needed here).

It took me more than 60 hours only to get all the macro stuff working so please believe me."

 

I feel sorry for the guy. It reads like it was so painful to write a mock object framework and everything is so much more complicated that I doubt many people will get to actually use it - the learning curve is very steep (I'm trying it on for size as part of a TDD course for C++ I'm conducting - it is painful).
If a framework is hard to use, and that makes unit tests harder to write - it's hard to convince people to move to agile development, and sometimes with good cause - it might prove too much of an effort to be economically justifiable - everyone loses out.
My hope is that after a while with my course I'll be able to have some better technical knowledge about these subjects to provide a more concrete guideline I can publish online for unit testing in C++.  But, to do that, we actually have to make it work with a real product - so good luck to all of us :)
 
Currently, writing our own manual mock objects seems to be working (it's not very far from where Mockpp is these days - actually it feels less work to accomplish the same tests) but I'm not sure I fully grasp all of its concepts just yet, so I'll keep reading up more on it.

MSF is a fraud? A response

Blogger dinner with Johanna Rothman - Rescheduled