0

Am very new to GTest. Now am performing GTest for my project.

In my class I have both private and public access specifiers. I can able to call the public methods by creating objects. But I cant able to test private methods in the same way.

Need some suggestions to access private methods in the class.

Similar class example

Class myproject
{
 public :
   void sendChimePlayrequestOn(); 
   void sendChimePlayrequestOff();
   virtual void OnMessage( const sal::Message& msg );
  private :
    void sendHeartBeat();
    void onStartingExecute();
};

How to access these private functions, some are just defined not accessible through public methods also.

Kiran JP
  • 45
  • 6
  • 1
    `not accessible through public methods also.` if the functions are not reachable by the client code, why testing them at all? – The Dreams Wind Aug 30 '22 at 11:12
  • don't. Test the public interface. Tests should not need to be rewritten when internal implementation details change. Or think in TTD, tests you write before you implement the functions can only test public interface, because implementation details arent there yet – 463035818_is_not_an_ai Aug 30 '22 at 11:13

0 Answers0