Googletest GTEST期间未调用模拟类函数

Googletest GTEST期间未调用模拟类函数,googletest,Googletest,我正在测试GTEST,在这里我模拟调用函数和类,但不调用模拟函数,而是调用原始函数 我创建了mock类,还更新了linkopt 如下 linkopt-W1,--wrap=\u ZN19MoneyInstrument31getUserMoneyInstrumentMapPBEP18TransactionHandlerP15BusinessContextRK7DBHost 模拟班 名称空间工具 { 类MockUserMoneyInstrumentMapPB:public UserMoneyInstr

我正在测试GTEST,在这里我模拟调用函数和类,但不调用模拟函数,而是调用原始函数

我创建了mock类,还更新了linkopt 如下

linkopt-W1,--wrap=\u ZN19MoneyInstrument31getUserMoneyInstrumentMapPBEP18TransactionHandlerP15BusinessContextRK7DBHost

模拟班
名称空间工具
{
类MockUserMoneyInstrumentMapPB:public UserMoneyInstrumentMapPB
{
公众:
静态UserMoneyInstrumentMappBPPTR m_user_Money_instrument_map_pb;
MockUserMoneyInstrumentMapPB(TransactionEntity*_th,ProductContext*_context):UserMoneyInstrumentMapPB(_th,_context)
{
}
静态无效集合\实例(MockUserMoneyInstrumentMapPB*\用户\货币\工具\地图\ pb)
{

std::cout声明中使用的损坏名称

MoneyInstrument::UserMoneyInstrumentMapPBPtr  __wrap__ZN19MoneyInstrument31getUserMoneyInstrumentMapPBEP18TransactionHandlerP15BusinessContextRK7DBHost(TransactionHandler *_th, BusinessContext *_context, const DBHost &_db);
以及功能的定义

Money::UserMoneyMapPBPtr  __wrap__ZN19Money31getUserMoneyMapPBEP18TransactionHandlerP15BusinessContextRK7DBHost(TransactionHandler *_th, BusinessContext *_context, const DBHost &_db)
它们不一样

当您在extern“C”块中声明损坏的函数名时,GTest将调用原始函数,但不会在模拟类中给出相同的定义。添加与extern块中相同的损坏名称的函数定义将解决此问题

TEST_F(bli_test,test1)
{
    MockUserMoneyInstrumentMapPB *m_mock_ufim_pb = new MockUserMoneyInstrumentMapPB(m_th, m_context);
    MockUserMoneyInstrumentMapPB::set_instance(m_mock_ufim_pb);

    TArray<UserMoneyInstrumentMapBDOPtr> ufim_bdo_array;

    EXPECT_CALL(*m_mock_ufim_pb,load_by_account_number(_)).WillOnce(Return(ufim_bdo_array));

    m_mock_bli_test->load_preferences(account_number,preference_type,search,list);
}
MoneyInstrument::UserMoneyInstrumentMapPBPtr  __wrap__ZN19MoneyInstrument31getUserMoneyInstrumentMapPBEP18TransactionHandlerP15BusinessContextRK7DBHost(TransactionHandler *_th, BusinessContext *_context, const DBHost &_db);
Money::UserMoneyMapPBPtr  __wrap__ZN19Money31getUserMoneyMapPBEP18TransactionHandlerP15BusinessContextRK7DBHost(TransactionHandler *_th, BusinessContext *_context, const DBHost &_db)