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 objects. It 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#. To the best of my knowledge, this is the first mocking framework of this kind available in C++.
Some of the most important features of RudeMocks are:
- Easily create mocks for
- Classes with single inheritance
- Classes with multiple inheritance
- Free functions and static member functions
- Flexible, per-argument expectations
- Natural syntax to set up expectations (just call the functions on the mocked object as usual)
- Use operator == to check for equality or fall back to memcmp
- Ignore specific arguments or all arguments
- Custom constraints on any argument
- STL container constraints
- Classes need not be default constructible (although a default value for classes used as return value types needs to be provided)
- 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++ 8.0 compiler. Ports to gcc 4.x and other CPU architectures are underway or in preparation.
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.
RudeMocks is developed by Martin Ecker who can be contacted at the email address me@<thisdomain>.com, or @martin_ecker on Twitter, or via his website.
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment