---
title: "Mockpp - Mock Objects for C++"
url: "https://osherove.com/blog/2004/12/7/mockpp-mock-objects-for-c.md"
canonical: "https://osherove.com/blog/2004/12/7/mockpp-mock-objects-for-c.html"
published: "2004-12-07T00:02:00"
updated: "2004-12-07T00:02:00"
tags: ["Agile Related"]
author: "Roy Osherove"
description: "Yeah, I know that what I quoted the other day about C++ is not entirely correct. You do have a mock object framework for C++. Here's a part of the documentation for Mockpp : \"But let me warn you If you take the wrong…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Mockpp - Mock Objects for C++

By Roy Osherove December 7, 2004 In [Agile Related](https://osherove.com/blog/category/agile-related)

**Historical article** · Originally published December 7, 2004; technical details may be outdated.

Yeah, I know that what I quoted the other day about C++ is not entirely correct. You **do** have a mock object framework for C++. Here's a [part of the documentation](http://mockpp.sourceforge.net/hb/ch01s03.html) for [Mockpp](http://mockpp.sourceforge.net/):

_**"But let me warn you**_

_If you take the wrong macro or maybe just have a small typo you will get loads of error messages all pointing to the same line. You will have no idea where to start and search the problem. I strongly recommend to take little steps when setting up such objects: add one single method and compile. Continue only if it compiled flawlessly._

_If you don't take care you will quickly find out why_ [_macros are evil_](http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-38.4) _and should be avoided where ever possible (unfortunately they are needed here)._

_It took me more than 60 hours only to get all the macro stuff working so please believe me."_

I feel sorry for the guy. It reads like it was so painful to write a mock object framework and everything is so much more complicated that I doubt many people will get to actually use it - the learning curve is very steep (I'm trying it on for size as part of a TDD course for C++ I'm conducting - it **is** painful).

If a framework is hard to use, and that makes unit tests harder to write - it's hard to convince people to move to agile development, and sometimes with good cause - it might prove too much of an effort to be economically justifiable - everyone loses out.

My hope is that after a while with my course I'll be able to have some better technical knowledge about these subjects to provide a more concrete guideline I can publish online for unit testing in C++.  But, to do that, we actually have to make it work with a real product - so good luck to all of us :)

Currently, writing our own manual mock objects seems to be working (it's not very far from where Mockpp is these days - actually it feels less work to accomplish the same tests) but I'm not sure I fully grasp all of its concepts just yet, so I'll keep reading up more on it.

## More in Agile Related

[All posts in Agile Related](https://osherove.com/blog/category/agile-related)

- Dec 10, 2004

    ### [I changed my mind - Mock objects are wrong for database unit testing](https://osherove.com/blog/2004/12/10/i-changed-my-mind-mock-objects-are-wrong-for-database-unit-t.html)

- Dec 7, 2004

    ### [MSF is a fraud? A response](https://osherove.com/blog/2004/12/7/msf-is-a-fraud-a-response.html)

- Dec 5, 2004

    ### [Extending NUnit \*easily\* with version 2.2.1 (finally!)](https://osherove.com/blog/2004/12/5/extending-nunit-easily-with-version-221-finally.html)

- Dec 2, 2004

    ### [Nice Agile blog](https://osherove.com/blog/2004/12/2/nice-agile-blog.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
