Sep 27

Setting up the gmock Windows project

Setting up the gmock Windows project


Example diagram:




Theoretical Background:


gmock is a framework that provides an API for easily setting up mock classes, to be used by your tests. It is also developed by Google and is intended to complete the testing capabilities of gtest. (Although you can use gmock with frameworks other than gtest)


In this article we will set up a windows project for gmock.

This project will be a static library that compiles the gmock code.

After creating this project we will be able to create our own test project that will take dependency upon this gmock project and the gtest project we created in an earlier article


Setting up the project:


1. Downloading gmock

We can download gmock from: https://code.google.com/p/googlemock/


Setting up the gmock project: (This part is the same as setting up the gtest project)


2. Moving the gmock folder to our cross platform files structure

We will put the gmock folder under:



3. Create an empty project and making it a static library

We will create in out CrossPlatformProjectExampleCore solution, under the TestProjects sub folder.

After creating an empty project we will set it as a static library:



We will not use a pre compiled header file in this project, we will set it by:



4. Setting the project to compile gmock

According to the instructions for building that are located under the README file in the downloaded gmock folder, all we have to do is add to our project the gmock-all.cc that is found in the gmock/src folder.


5. Adding the include directories

We need to add to following directories to the Additional Include Directories:







6. Set the gmock project to take dependency upon the gtest project




7. All that is left now is to compile the project


That is it,

In the next article I will go over and how to create a test project that will test our source code using the gmock and gtest framework and will also provide a link to download the project we created so far


Good luck !

Leave a Reply

Your email address will not be published.

אתם יכולים להשתמש באפשרויות ותגי ה-HTMLהבאים: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>