Aug 29

Setting up the gtest Windows project

:Setting up the gtest Windows project


Example diagram:




Theoretical Background:


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

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

After creating this project we will be able to create our own test project that will take dependency upon this gtest project.


Setting up the projects:


1. Downloading gtest

We can download gtest from: https://code.google.com/p/googletest/downloads/list


Setting up the gtest project:


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

We will put the gtest folder under:



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

We will create a folder under our CrossPlatformProjectExampleCore solution, in this folder we will create the static library project.

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 gtest

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


5. Adding the include directories

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




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


Link to download the example project


That is it,


In the next article I will go over the gmock framework and then we will create a sample project that take dependency upon gtest and gmock in which we will write our tests.


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>