Saturday, 31 January 2015

SetUp Google Mock (Google Test ) in Ubuntu 14.04

Google C++ Mocking Framework (or Google Mock for short) is a library for writing and using C++ mock classes. Google Mock:
  • lets you create mock classes trivially using simple macros,
  • supports a rich set of matchers and actions,
  • handles unordered, partially ordered, or completely ordered expectations,
  • is extensible by users, and
  • works on Linux, Mac OS X, Windows, Windows Mobile, minGW, and Symbian.     

In this post i will be covering the procedure to install GMock in Ubuntu. Below are the steps:
  1. Download GMock from https://code.google.com/p/googlemock/downloads/list and extract it to a folder (Lets say $(GMOCK_DIR))
  2. GMock already has a copy of GTest inside it , so there is no need to get another copy of GTest.
  3. If cmake is not installed , install cmake using command sudo apt-get install cmake
  4. Go to GMock Directory using command cd $(GMOCK_DIR)    
  5.  Run command cmake CMakeLists.txt and then make
  6. This will create a library libgmock.a in your current directory.
  7. Now your GMock and GTest setup is ready.