
On Wed, Jun 10, 2009 at 2:43 AM, Peter Bindels<dascandy@gmail.com> wrote:
Hi all,
Over the past three-quarters of a year I've been working (with three friends) on a mocking framework for C++. In our vision, it would be a good complement to Boost.Test for testing classes separate from interfaces required - it would improve the ability to unit-test the classes that tie others together and that implement higher-level algorithms.
It does this by creating an object that is "derived" from a given class at runtime, and replacing the functions with functions that redirect to verifying logic. The verifying logic uses basic structures to record expectations and to verify they happened. These ways of creating an object at runtime and modifying it are highly compiler dependant but remarkably portable - as it runs on at least 3 different compiler series (GCC, MSVC, EDG-based) and 5 platforms (Windows XP, Windows CE, Linux, QNX, bare platform), with few modifications.
This is a great idea for polymorphic interfaces but some interfaces are not polymorphic. It would be nice if we could provide a mock implementation of the internal interface even in case none of the calls to that interface are virtual. Think C API used as your internal interface: struct bar; bar * create_bar(....); void destroy_bar( bar * ); void use_bar( bar * ); Basically you can alter the implementation by just linking with a different library instead of bar (I'm not sure how this would work with the rest of the mock library.) Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode