What is the difference between gtest and gmock?

"Google Mock is not a testing framework itself. Instead, it needs a testing framework for writing tests. Google Mock works seamlessly with Google Test. It comes with a copy of Google Test bundled. Starting with version 1.1.0, you can also use it with any C++ testing framework of your choice. " - Google Mock, System Requirements

Mock are like objects, defined in such a way to mimick the real-deal by supplying controlled behavior. For instance, to test a stock tick application, you'd create a fake stock data provider that created fake stock quotes to test your code with. Think of the word mock, literally means 'to mimic'.


Software units do not live in green meadows. They very often need some counterparts to do the work. In real system, these counterparts belong to the system itself. In the unit tests they are replaced with mocks.

Gtest is a framework for unit testing. Gmock is a framework imitating the rest of your system during unit tests.