I tried to create a very simple Mock Class as per Getting Started of gMock for Dummies.
I created a new blank project in VS Studio 2019
I ran the package manager
Install-Package gmock -Version 1.8.1
as per this answer Configure GoogleMockThe packages.config file that got created
<?xml version="1.0" encoding="utf-8"?>` <packages> <package id="gmock" version="1.8.1" targetFramework="native" /> </packages>
I created 1 file Source.cpp
class Turtle { virtual void PenUp(); }; void Turtle::PenUp() { return; } #include "gmock/gmock.h" class MockTurtle : public Turtle { public: MOCK_METHOD(void, PenUp, (), (override)); // not working see Pic1 MOCK_METHOD0(PenUp, void()); // not working see Pic2 };
The 2nd example tries a syntax like this answer How to mock method
Pic1:
Pic2: