MockItNow: Throwing Exceptions

I’ve made a small update to MockItNow to allow you to throw exceptions when replaying function calls. You basically record the function call as normal, and provide the exception object that you want to throw during the replay using the EXPECT_THROW macro. You can also make a function default to throwing an exception at registration time using REGISTER_THROW. If you want to see a couple of examples of this feature, take a look at the bottom of the sample file here.

Minor Update to MockItNow

This is just a quick note to say that I’ve updated MockItNow on Google Code to allow you to define storage types on a per-class basis using the DECLARE_STORAGE_TYPE macro. I did this so that the Mocker can deal with abstract class parameters. Please note that the macro must be declared at global scope because it uses partial template specialization. I updated the download, and the source. You can see the new test at the end of the file here, and the only other affected file is Storage.h. Thanks to Lance for…

MockItNow: Sample Code Added

I’ve just uploaded a sample project for MockItNow to Google Code. Get it here. This file includes the Examples project, the latest version of MockItNow, and UnitTest++. The projects are provided in Visual Studio 2005 format, and should compile out of the box. Please note that this is a slightly modified version of UnitTest++, since the current release doesn’t catch std::exception in all cases. I’m going to work with Charles at some point to integrate these changes back into the main branch of UnitTest++. I’ve provided three configurations for the…

MockItNow: Redirecting Function Calls in C++

This is the first in a short series of articles I’m going to write about the way MockItNow works. I’m going to start off with something pretty meaty: How does MockItNow intercept the function calls and redirect them? I tried a few ways of intercepting function calls and recording their parameters, and maybe one day I’ll explain ways not to do it, but for now, read on if you’re interested in how it works at the moment.