Skip to content

Instantly share code, notes, and snippets.

View ProExpertProg's full-sized avatar

Luka Govedič ProExpertProg

View GitHub Profile

THIS IS STILL A DRAFT - come back soon for an updated version. It has not been tested, just an idea for now.

Abstract

GoogleTest is one of the most popular testing frameworks in C++. It also includes GoogleMock, a comprehensive mocking framework.

GoogleMock works by extending the class we are trying to mock and providing own implementations of the methods. However, because of that, it does not allow mocking of nonvirtual methods. The GoogleTest guide recommends coding to interfaces, where we mock interfaces rather than concrete implementations. That can be a good approach in massive enterprise applications, however, C++ is often chosen for performance-critical reasons. In such cases, we cannot afford to make all public functions virtual

  • there are also other drawback which I descibe in more detail below.