6

I am searching for a mocking framework for a large C++ project. I've tentatively chosen GoogleTest as the testing framework so I first looked at GoogleMocks. However, I then discovered TypeMock's Isolator++ which has two features I very much liked:

  1. It can mock anything.
  2. It allows you to add test coverage without changing legacy code (using method call interception & maybe some other magic). No need to splice in interfaces to add tests.

The drawback is that Isolator++ is a commercial product. I worry about vendor lock-in & such. Are there other frameworks which have the same capabilities? Perhaps something open source?


Let me also preclude a common criticism I've observed in other posts: "TypeMock encourages bad design. You should improve your design rather than use a tool which supports bad habits." (my paraphrase)

My response is this: I do want to improve design. I also want to add test coverage BEFORE refactoring. To that end, the ability to add tests with zero code changes is very attractive.

  • I'm not sure why "vendor lock-in" is a greater bugaboo than untestable legacy code. While TypeMock may allow you to be "lazy" about re-writing code, you can't really refactor code until you have tests in place to see that refactoring isn't hurting. – Bob Dalgleish Nov 11 '14 at 0:38
  • It certainly isn't the greater "bugaboo" :), but I just wanted to see if there were alternatives before dropping the cash. – Joe Schrag Nov 11 '14 at 15:12
1

Well, I suppose this post could also be titled: "Does TypeMock Isolator++ have any competitors"? As far as I can tell, the answer is no.

For C# code, TypeMock Isolator does have a couple competitors: Telerik JustMock & Microsoft Fakes. However for C++, TypeMock Isolator++ is the only one I've found.

For anyone in this situation, I also suggest a reading of Michael Feather's book "Working Effectively with Legacy Code". It offers many practical tips for getting tests in place without needing to mock live objects as Isolator lets you do. That said, there are cases where the necessary changes are simply too invasive in my opinion. They introduce too much risk while getting tests in place. So, perhaps Isolator++ might be worth the money. We'll see...

Update: I spent about three days trying to get a single test running with Isolator++ before I gave up, so we decided to go without.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.