Unlike Java or other languages where reflection / introspection is available, mocking is not easy with C++. Even with Google Mock, we need some hand writing.

I solved this problem by using home made class declaration parser/generator that reads the class declaration (header file), then generates a mock class.
What you need is to run the generator and full featured mock class is there for your unit test.

----
How to use:
You need Ruby. Obtain it if you don't have it yet.

Get Tools
At your convenient directory:
git clone https://git.code.sf.net/p/cpp-tools-in-ruby/code tools

Get Mocker++11
git clone https://git.code.sf.net/p/mockerplusplus11/code mocker++

Run it
Change directory to mocker++
./Mocker++ --help
(On Mac/Unix, you may need to run dos2unix)

Code samples (unit test codes) are found in 'unittest/MockerppTest

Project Activity

See All Activity >

Follow Mocker++11

Mocker++11 Web Site

Other Useful Business Software
Enterprise-grade ITSM, for every business Icon
Enterprise-grade ITSM, for every business

Give your IT, operations, and business teams the ability to deliver exceptional services—without the complexity.

Freshservice is an intuitive, AI-powered platform that helps IT, operations, and business teams deliver exceptional service without the usual complexity. Automate repetitive tasks, resolve issues faster, and provide seamless support across the organization. From managing incidents and assets to driving smarter decisions, Freshservice makes it easy to stay efficient and scale with confidence.
Try it Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Mocker++11!

Additional Project Details

Intended Audience

Developers

Programming Language

C++, Ruby

Related Categories

C++ Software Testing Tool, C++ Parser Generators, Ruby Software Testing Tool, Ruby Parser Generators

Registered

2015-09-23