RunTime failure in gmock unit testing

Hi,

I am trying to run the unit tests written using gmock.
While running, I am getting unit test failure as the function call becomes uninteresting.

I have added the EXPECT_CALL macro with WillOnce frquency. So cardinality becomes 1.

Following calls in my unit test function never get called during unit test run.
The original function I am testing is virtual. Also, both the functions in below EXPECT_CALL macro are virtual. These functions are called in original function one after the other. So I have added EXPECT_CALL macros to get the desired return value for these functions.

EXPECT_CALL(l_objSomeHandler, storeSomeData(_,_))
.WillOnce(Return(true));

EXPECT_CALL(l_objSomeHandler, generateRandomString())
.WillOnce(Return(l_strRandomString));

It shows the following error :
Expected: to be called once
Actual: never called - unsatisfied and active (for above both functions)

The function being tested becomes uninteresting. The function getrs failure.

Also, I have observed a different behavior. For the very first time, the unit test was correctly executed and result came out to be a PASS.
Next time, same unit test got failure. In each subsequent attempt, I am getting failure constantly.

I have derived my unit test class from the class whose functionality is being tested.

Can you please guide me if I am missing something?
Last edited on
Topic archived. No new replies allowed.