RudeMocks - A C++ Mocking Framework
(C) Copyright 2007-2012 Martin Ecker
For more information and documentation on this project please see
RudeMocks is a mocking framework for C++ that allows you to easily
create mock objects and set up expectations on them using a
record & replay model by simply calling functions on the mock
RudeMocks is inspired by C# mocking frameworks, such as Rhino Mocks
and TypeMock. The goal of RudeMocks is to nearly eliminate the need
to write mocks by hand when writing unit tests in C++. It is a
useful library for test-driven development in C++ and makes writing
unit tests almost as easy as in Java or C#.
Some of the most important features of RudeMocks are:
* Easily create mocks for
o Classes with single inheritance
o Classes with multiple inheritance
o Free functions and static member functions
* Flexible, per-argument expectations
o Natural syntax to set up expectations (just call the
functions on the mocked object as usual)
o Use operator == to check for equality or fall back to memcmp
o Ignore specific arguments or all arguments
o Custom constraints on any argument
o STL container constraints
* Classes need not be default constructible (although a default
value for classes used as return value types needs to be
* Fully unit tested
The name RudeMocks comes from the fact that the implementation
uses inline assembly, which in some C++ circles is considered
a bit rude. The use of a little bit of assembly makes the
implementation dependent on the compiler and the CPU architecture.
The current implementation supports x86 CPUs and the Microsoft
Visual C++ compiler from version 8.0 (Visual Studio 2005) onward.
MingW gcc 4.2.1 (and higher) are also supported. Porting the
library to Linux should be easy (probably just recompile),
however the author hasn't tested this. Contributions in this
area are more than welcome.
A port to the x64 CPU architecture is underway.
RudeMocks only depends on and uses the C++ standard library and
Boost. It is released under the zlib/libpng license and can be
used freely in non-commercial and commercial products.