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
Im currently using vs2008 with asp.net mvc framework for web development. Im missing a
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
Currently using ColdFusion 8 enterprise on 32 bit linux box to send out our
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
I'm currently using the Mootools Element constructor method to dynamically add a new row
I'm currently using the resourceBundle variable to get text values in my JSF code
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. I
I'm currently using VS2005 Profesional and .NET 2.0, and since our project is rather
I am currently using Windows Server 2008 Standard and have several Hyper V machines.

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.