mercredi 27 avril 2016

C++, Googlemock - testing local object

I started to use googletest and googlemock libraries and I have a problem which I cannot solve. I have a code something like this:

class Painter
{
  public:
  void DrawSomething();
};

void Painter::DrawSomething()
{
  Turtle turtle;
 turtle.doSomething();
}

main()
{
  Painter p;
  p.DrawSomething();
}

I have mocked the Turtle class but how can I test doSomething() method (for example with EXPECT_CALL) when the object of turtle is created locally? Is it possible without modifying Painter class?

Thank you for answers.

Aucun commentaire:

Enregistrer un commentaire