As said in the title, I try to test my code using google test, but I get some issue on inheritance of mocks. I will further present the structure of my code: file1.hpp
struct A: virtual public testing::Test
{
//function with MocksA
};
file2.hpp
struct B: virtual public testing::Test
{
//function with MockB
};
file3.hpp
include file1 & file2
class C: public B, public A
{
//call MockB -> fails here
};
If I only use the inheritance on "public B" or would put "public B" on 2nd position, the code works. However, I need both A & B to be tested in my class C and would get the same error for A (or B, depending the position).
How can I include both files and use their mocks?
P.S: both A&B have different names for MOCKS and would not influence one another. P.S 2: If situation is as above, I get: unknown file: Failure C exception with description " The mock function has no default action set, and its return type has no default value set." thrown in the test body.
Actual function call count doesn't match EXPECT_CALL(...,.. )... Expected: to be called once Actual: never called - unsatisfied and active
CodePudding user response:
The solution was to add EXPECT_CALLS in the 3rd file, not using the ones from file1 & file2