Hej,
posiadam następującą, uproszczoną hierarchię klas:
class MockA : public A
{
...
MOCK_METHOD( funA, void());
...
}
class MockB : public B
{
....
MOCK_METHOD0( funB, void()();
...
}
Chciałbym, żeby w testach podczas wywołania funckji funA jej mock wywołał mocka funB, co zrobiłem w następujący sposób:
...
MockA* m_a_ptr;
StrictMock<MockB> m_b;
EXPECT_CALL(*m_a_ptr, funAl()).WillRepeatedly((Invoke(&m_b, &MockB::funB)));
...
Niestety otrzymuję błąd:
googletest/1.7.0-28/include/gmock/gmock-generated-actions.h: In instantiation of 'static R testing::internal::InvokeHelper<R, std::tr1::tuple<A1> >::InvokeMethod(Class*, MethodPtr, const std::tr1::tuple<A1>&) [with Class = testing::StrictMock<MockB>; MethodPtr = bool (MockBl::*)() const; R = void; A1 = SIGNAL*&]':
/googletest/1.7.0-28/include/gmock/gmock-more-actions.h:80:36: required from 'Result testing::internal::InvokeMethodAction<Class, MethodPtr>::Perform(const ArgumentTuple&) const [with Result = void; ArgumentTuple = std::tr1::tuple<SIGNAL*&>; Class = testing::StrictMock<MockBl>; MethodPtr = bool (MockB::*)() const]'
/googletest/1.7.0-28/include/gmock/gmock-actions.h:371:49: required from 'testing::PolymorphicAction<Impl>::MonomorphicImpl<F>::Result testing::PolymorphicAction<Impl>::MonomorphicImpl<F>::Perform(const ArgumentTuple&) [with F = void(SIGNAL*&); Impl = testing::internal::InvokeMethodAction<testing::StrictMock<MockB>, bool (MockB::*)() const>; testing::PolymorphicAction<Impl>::MonomorphicImpl<F>::Result = void; testing::PolymorphicAction<Impl>::MonomorphicImpl<F>::ArgumentTuple = std::tr1::tuple<SIGNAL*&>]'
/test/gtest/src/classTests.cc:11340:1: required from here
/googletest/1.7.0-28/include/gmock/gmock-generated-actions.h:83:47: error: too many arguments to function
return (obj_ptr->*method_ptr)(get<0>(args));
/googletest/1.7.0-28/include/gmock/gmock-generated-actions.h:83:47: error: return-statement with a value, in function returning 'void' [-fpermissive]
^