Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
minor formatting
Source Link
GhostCat
  • 140.8k
  • 28
  • 190
  • 262

My question is the same as Mockito: Mock private field initialization but for Google Mock framework.

  In a nutshell:

class Target { private: Person person = new Person(); public: void testMethod() { person.someMethod(); } }; 

How can I mock the person instance while making unit tests for Target class?

My question is the same as Mockito: Mock private field initialization but for Google Mock framework.

  In a nutshell:

class Target { private: Person person = new Person(); public: void testMethod() { person.someMethod(); } }; 

How can I mock the person instance while making unit tests for Target class?

My question is the same as Mockito: Mock private field initialization but for Google Mock framework. In a nutshell:

class Target { private: Person person = new Person(); public: void testMethod() { person.someMethod(); } }; 

How can I mock the person instance while making unit tests for Target class?

added C++ tag
Link
duong_dajgja
  • 4.3k
  • 4
  • 40
  • 68
Source Link
duong_dajgja
  • 4.3k
  • 4
  • 40
  • 68

Google Mock: Mock private variable member that is instantiated in target class's constructor

My question is the same as Mockito: Mock private field initialization but for Google Mock framework.

In a nutshell:

class Target { private: Person person = new Person(); public: void testMethod() { person.someMethod(); } }; 

How can I mock the person instance while making unit tests for Target class?