I have the following scenario where I am invoking EXPECT_CALL
to set the return value of the function Foo
to true
however I am getting the following error
Actual: never called - unsatisfied and active
One essential thing I have seen is passing an object to EXPECT_CALL
which is the case here. As in classPtr
is a valid pointer to the MockClass
object.
// Class Under Test
class Feature
{
[[maybe_unused]] virtual bool Foo(const std::string& digit, int number);
};
// Mock class
class MockClass : public Feature
{
public:
MOCK_METHOD(bool, Foo, (const std::string& digit, int number),
(override));
};
// Test class
class UtClass : public Ut
{
public:
std::unique_ptr<MockClass> classPtr = std::make_unique<MockClass>());
}
TEST_F(UtClass, Test)
{
EXPECT_CALL(*classPtr, Foo("A", 5))
.WillOnce(Return(true)); // Actual: never called - unsatisfied and active
}