mercredi 15 avril 2020

Mocking Static Method in c++

I just started working on unit testing using googleTest. I have a situation where I have a static method of one class is calling inside the other class

class A {
  public:
   static bool retriveJsonData(std::string name, Json::Value& responseJsonData);
}

In other class i am using the Class A retriveJsonData method.

class B {
   public:
     bool Method1 (std::string name) {
        Json::Value sampleJsonData;
        return A::retriveJsonData(name, sampleJsonData);
 }

Mocking of class A

class MockA : public A {
  public:
    MOCK_MEHTOD2(retriveJsonData, bool(std::string, Json::Value));

}

Now I have to mock retriveJsonData in Testing of Method2 of class B using EXPECT_CALL.

Please help me to resolve how can I test this situation?

Aucun commentaire:

Enregistrer un commentaire