An Automated Mock Object Generator for C++

GLSEC 2007
November, 2007

Scott Miller & Greg Pattison

Abstract

Interaction-based unit testing using mock objects is becoming very popular. Libraries to generate mock objects exist for many platforms and languages, but C++ seems to be a notable exception. This talk presents a library that generates mock objects directly from the definition of an interface in C++ code. Using these generated mock objects, a C++ developer can set expectations and verify the interaction of classes and objects in a manner very similar to more modern languages.

Description

This library uses a combination of code generating python scripts and a few class definitions in generic C++ to provide the functionality of recording expectations, playing those expectations back during the exercise of a method under test, and verifying that all expectations were met correctly.

We will be discussing the testing issues that led us to create this tool, how mocking for the purpose of performing interaction-based unit tests works, and some of the specifics of how this library successfully handled the workload.

After attending this session, you will have a better understanding of how mocks do what they do, and why. You will also receive the fully functional mock generator to examine or use in your C++ projects.

An Automated Mock Object Generator for C++ [PDF]

Moxy Mock Object Library and Examples

Copyright © Atomic Object LLC. - Grand Rapids, MI 49506 - (616) 776-6020 - Contact Us

Edit