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…
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…
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…
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 =…
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…
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…
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…
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)…
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?
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?
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…
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()…
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…
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…