Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6070621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:57:15+00:00 2026-05-23T09:57:15+00:00

I am currently using HippoMocks as mocking framework, and can’t figure out how to

  • 0

I am currently using HippoMocks as mocking framework, and can’t figure out how to mock the pure virtual method MockMe() in the code below. I do not want to mock any of the non-virtual methods (which is likely not even possible), instead I want them to do what they are meant for and call the mocked virtual one.

struct A
{
  void Run() { RunImpl(); }
  virtual void RunImpl() = 0;
};

struct B : public A
{
    //implement A::RunImpl
  void RunImpl() { MockMe(); }

    //this one I want to mock
  virtual void MockMe() = 0;
};

MockRepository mocks;
B* b = mocks.InterfaceMock< B >();
mocks.OnCall( b, B::MockMe );
b->Run(); //throws NotImplementedException for Run()

Is there any way to get this working with HippoMocks? Or with another framework? Or with some source modifications?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:57:16+00:00Added an answer on May 23, 2026 at 9:57 am

    update/answer: I found a way around it by deriving a new class from B and adding a helper to forward the calls to the appropriate method. Apart from that it’s also important to use ClassMock instead of InterfaceMock.

    So, using the example above, this works:

    struct MockHelper : public B
    {
      void InvokeRunImpl()
      {
        B::RunImpl();
      }
    
      virtual void MockMe()
      {
        //never called, but must be defined so MockHelper can be instantiated
      }
    };
    
    MockHelper* b = mocks.ClassMock< MockHelper >();
    auto invokeIt = [b]() { b->InvokeRunImpl(); };
    mocks.OnCall( b, MockHelper::RunImpl ).Do( invokeIt );
    mocks.OnCall( b, MockHelper::MockMe );
    //ok now: calls A::Run, which calls mocked RunImpl, which in turn
    //calls InvokeRunImpl, which in turn calls B::RunImpl
    b->Run();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im currently using a method that looks like the following code to add script
Currently Using: Spring Tools Suite v2.7.2 Spring Framework v3.0.5 Sample Code in a controller:
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
I'm currently using the validation code listed here in an application. I'd like to
I am currently using a javascript code to make an entire row in my
Currently using: @^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?$ How can i make http:// not compulsory but if it does
Our team is currently using some ported code from an old architecture to a
Currently using ColdFusion 8 enterprise on 32 bit linux box to send out our
Im currently using C# to pass some objects to powershell and executing a method
Im currently using vs2008 with asp.net mvc framework for web development. Im missing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.