dimanche 7 juin 2015

Google Mock without using the mocked object directly (C++)

I am new to Google Mock. I have a class A, that is using class B. I want to write a test that will test A, without running B, as B is using the outside world.

My question: How can I invoke a test on A, and have it use the Mocked instance of B?

E.g.

A a;
Mock_B mock_b;
EXPECT_CALL(mock_b, foo(4));

//test call of a
EXPECT_EQ(0, a.bar());

When I an doing this, a is using B rather than Mock_B.

Thank you for your help, Ziv

Aucun commentaire:

Enregistrer un commentaire