Home

Hippo Mocks

What's new with Hippo Mocks

2009-08-09 Release version 3.1

The 3.1 release is here now. Download Hippo Mocks 3.1 here.

To be quite honest, this release is already a few months old. I've neglected updating the front page too long and forgot to add it here. My sincerest apologies for not updating it; my only excuse was getting married but that's been about two months already. Emails and direct questions from multiple people attended me to the fact that the changes between 3.0 and 3.1 were actually much desired:

There's also a single change that nobody asked for, but that is a consequence of the GreenHills support:

2009-04-23 Release version 3.0

The 3.0 release is here already. Download Hippo Mocks 3.0 here. It contains a bug fix (reference return didn't work), lots of enhancements (exception detail, registering expected-but-wrong calls and other minor improvements) and adding a few hooks for adjusting its behaviour. It is not version 2.1 in that it has two breaking changes. The first is that the ampersand before the function name is now forbidden. The second is that objects that used to give a compile error on not being comparable with operator== now give a false value back indicating they're not the same.

2009-03-26 Release version 2.0

Today we've released the 2.0 version of Hippo Mocks. Download Hippo Mocks 2.0 here. It has much less memory leaks (probably not none yet, but we're removing them as we notice them). We've spiced up the warning resilience and it compiles warning-free on the highest warning levels of GCC (4.3.3), Visual Studio (2008, 9.0) and Comeau (4.3.10.1).

The syntax has made a few slight changes. The function ReplayAll() has been removed. It serves no purpose (and never has). VerifyAll() has been moved to the destructor so that all expectations are implicitly checked during the finalization of your test. This assumes that you have a mock repository per test. If you have one mock repository for a group of tests, you can use the VerifyAll() function and the reset() function to reuse it for another time. Loads of code have been removed to make the code that bit more readable. It's slightly over 2000 lines now.

There is a C++0x version! After a long and arduous journey, through the perils of ..... No actually, it only took about 3 hours to make it in total, and it's even much smaller than the non-0x version. This version only has about 930 lines of code for exactly what the regular version can do, and it is less limited. Due to Microsoft's refusal to support variadic templates in Visual Studio 2010, it will not be usable in Visual Studio until at least 2012 (or thereabouts). Comeau also does not yet have variadic template support in their c++0x version, so GCC remains the only compiler that supports it.

Why Hippo Mocks

Does it work for me?

Whether the syntax is the one you prefer is a personal choice, for which we have a comparison. Whether it can work on your platform is a technical issue, for which we have an overview.

Why the name Hippo Mocks

In creating Hippo Mocks we took the syntax of Rhino Mocks as a guideline for a clear and readable syntax. We chose a different name from Rhino Mocks as we're not associated with Ayende (the author of ) and it would be an infringement on the name of Rhino Mocks to pretend to have something directly to do with it. On the other hand, we do have the same approach to the same problem, resulting in much the same solution. In an analogy to CppUnit with JUnit, we chose a relatable but different name.

Why create Hippo Mocks

There does not appear to be an easily usable mocking framework for C++ that allows you to instantiate derived types whilst making your test, without explicitly writing a few classes to do so. As this is prohibited by the language itself, it's understandable. It still is a much better way to do mocking and since it is technically possible (at least in Visual Studio and GCC), there should be a proper framework for doing so.

Why use Hippo Mocks

Since mocking frameworks all differ in syntax and thought patterns for use, you will find one of many to be most suitable for you, and not necessarily the one we made. Other mocking frameworks you may want to consider:

Amop
MockPP
MockitoPP
The Google mocking framework
MockItNow
M0cxx0r
Moxy

There are a few reasons why you may prefer Hippo Mocks:

How to use Hippo Mocks

I'm missing this one feature that would make it so much better for me

If you're in this situation there are three things you can do, in order of amount of convincing it involves:

I really like it, but I need you to come tell your story before my colleagues will accept it / for any other reason

In the same vein, I'm always open to telling the story behind Hippo Mocks or providing a compelling argument for using it. Not in the least because I'll fix your problems with it even if I don't agree with them when I do come for the talk. Just like consulting (just above), this requires some form of payment to refund my costs and time. Usually I'll make the presentations and so on for free.

Why use mocks in your tests

Should we use a mocking framework
When to use mocks
Mock roles, not objects [PDF]
Using mock objects effectively

Our opinion is that you use mocks to "fake" or hide the rest of your system in the same way you use headers to hide the knowledge of the implementation of classes. You would then also use mocks every time you use headers - IE, around the borders of each class under test. This makes the test rely solely on the behavior of the class you're testing. That means that when the test breaks, only the class under test needs to be considered.

Who made Hippo Mocks

We are Mike Looijmans and Peter Bindels, both working at Topic Automatisering. We decided that replacing functionality for the purposes of testing easily should be a base construct that is publicly available to everybody. Hence we created Hippo Mocks.

What license do you release it under?

We've decided to release it under the LGPL license. This license, in short, allows you to use it like the GPL would, with the exception that your software does not become GPLed by doing so. You are still strongly encouraged to send back changes you make.

Why do you release it for free?

There is a multitude of reasons why it is free.

On one hand there's a practical reason. If this were commercial, there would be no way to limit a trial version or a shareware version other than outright removing functionality, which makes upgrading harder and defeats the purpose of trial versions. Also, there is no way to determine if somebody used mocks to get his/her tests cleaner in order to get the product better - the final product most likely doesn't contain any mocks.

On the other hand there are a few ideological reasons. I believe that the way Hippo Mocks makes you write your tests is the way to write unit tests. It is an expressive language that allows you to say what your test should do, without obfuscating it or requiring you to type more than you should have to. I believe that software that is properly unit-tested is both easier to maintain and probably of a higher quality level than those that aren't. Because in the end I'll probably be a user of most software, I prefer that the developers of any software have the ability to use a good unit testing framework that keeps their code clean and makes it work properly and cleanly. In other words, doing this for "free" means that I get better products in the shops. It also gives me a warm fuzzy feeling inside to know that people appreciate what I'm doing.

If you do wish to do something to help Hippo Mocks (such as pay for it), you're invited to hire us to give a talk, add features for your benefit or make a donation. We also very much appreciate receiving post cards from wherever you live or any Hippo-related souvenirs. If you want to send us anything, please send it to Topic Automatisering, attn: Hippo Mocks, Eindhovenseweg 32-C, 5683 KH Best, The Netherlands.


Comments