Questions tagged [hippomocks]

A library for writing and using C++ mock classes

Hippo mocks is a c++ framework to create mock classes.

38 questions
1
vote
1 answer

HippoMocks: is it possible to mock non-virtual methods?

I've starting using HippoMocks for writing unit tests. I would like to know if it's possible to mock non-virtual class methods? A first look at the code seems to indicate that the framework only supports virtual methods. But as it supports the…
Serge Weinstock
  • 1,235
  • 3
  • 12
  • 20
1
vote
2 answers

Hippomocks expect call with class instance

How does one set up an expect call with a class instance or structure instance as one of the parameters in the "with" part? The documentation doesn't seem to show how to do that. I see using simple arguments like strings and integers - but not…
MKaras
  • 2,063
  • 2
  • 20
  • 35
1
vote
1 answer

HippoMocks - Mock a COM interface in C++?

The latest version of Hippo Mocks (in its Git repository) looks to have added support for COM interfaces. I've tried mocking an ADO connection object; which took some tweaking of Hippo Mocks to build properly (seems the COM version of the code…
Bret Kuhns
  • 4,034
  • 5
  • 31
  • 43
1
vote
1 answer

Can a mock be reused for multiple expected calls with different return values in Hippo Mocks?

I'm using Hippo Mocks to great success, but I have a situation that I can't quite figure out how to set up properly. The code under test looks sorta like this: auto firstName = record.at("firstName").getValue(); auto lastName =…
Bret Kuhns
  • 4,034
  • 5
  • 31
  • 43
1
vote
2 answers

HippoMocks mocking return values by ref

class IEmployeeServiceProxy { public: virtual ~IEmployeeServiceProxy() { } virtual void AddEmployee(const Employee&) = 0; virtual int GetEmployees(std::vector&) = 0; }; struct Employee { boost::uuids::uuid Id; …
Zach Saw
  • 4,308
  • 3
  • 33
  • 49
0
votes
1 answer

Call original/mocked function, from within mock

I'm trying to mock some WinAPI functions via hippomocks. How can I call the original/mocked WinAPI, from within the mock? For example, if I mock CreateFile, the logic I would like to implement inside the mock which I register via: MockRepository…
golosovsky
  • 638
  • 1
  • 6
  • 19
0
votes
1 answer

Hippomock static function with overload, how to use ExpectCallFuncOverload?

With the following class: class Math { public: static int Add(int a, int b) { return a + b; } static int Add(int a, int b, int c) { return a + b + c; } }; How to use ExpectCallFuncOverload? I try #include…
xibi
  • 101
  • 1
  • 8
0
votes
2 answers

Hippomocks pointer argument - provide input, check output

I have a function that expects a buffer length input in a pointer argument, and then puts the number of the read bytes into that same argument as output. Now in my unit test I try to mock it with Hippomocks, and would like to check if the function…
YaniMan
  • 293
  • 2
  • 13
0
votes
0 answers

How can I extract only the name of the defined function from a function like macro in C?

Let's say I want to have 2 modules, which are loosely coupled. The first module is depending on the interface of the other module. I would like to decouple them by introducing defines for the interfaces. In module1_cfg.h #define FUNC1_MODULE2(x)…
0
votes
1 answer

How to execute two instructions in a .Do()?

I would like to execute multiple instructions inside of a .Do(). Something like: mocks.ExpectCallFunc(mockedFunc).Do(a++;someFunc();) How can I make this happen?
Dan
  • 61
  • 12
0
votes
1 answer

Is there an analogous function like Do() for ExpectCallFunc or OnCallFunc?

For mocking member methods with ExpectCall or OnCall you can use the Do method. But for static functions if you try Do the compiler will tell you that Do is not a member of the Call class. Is there a similar mechanism?
0
votes
1 answer

Hippomocks: Attribute is Value not a pointer

I am new to Hippomocks and C++. I try to write an Unittest where an exception is catched. For this I have written the following test: #include #include "../Mocks/hippomocks.h" /////// Mocking Test Classes ///////////////////// class…
user7561458
0
votes
1 answer

Partial Class Mocking

I want to use hippomocks to mock a method in a class. That method is called by another method in the same class. As in... class Foo { public: Foo() {} virtual ~Foo() {} virtual string getName() { return "Joe"; } virtual void print()…
Trouble
  • 51
  • 3
0
votes
1 answer

HippoMocks: How to ExpectCall With an argument passed by reference?

While using Hippomocks, we are having difficulties expecting that a byref argument was passed to a function. class A { public: virtual ~A(); virtual void foo(IBar& callback, const unsigned x); }; IBar being an interface. I then have a…
Lee
  • 3
  • 2
0
votes
1 answer

HippoMock always throwing NotImplemented

I'm attempting to mock an Interface using HippoMock, for use in a class that makes use of said interface. I build a mock object and setup the ExceptCallOverload, everything compiles fine. However the the class I am testing makes a call to the mock…
Apeiron
  • 694
  • 7
  • 13