Questions tagged [hippomocks]

A library for writing and using C++ mock classes

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

38 questions
6
votes
1 answer

HippoMocks - mocking a function that returns a unique_ptr

I am currently not succeding in mocking an interface that returns a unique_ptr. For example, given struct IFoo { virtual std::unique_ptr foo = 0; }; int main() { MockRepository mocks; auto foo = mocks.Mock(); …
Thomas
  • 4,980
  • 2
  • 15
  • 30
4
votes
2 answers

How to intercept a free function call like hippomocks does?

I'm wondering what hippomocks does to intercept the exit call function for example as shown in the below code: MockRepository mocks; mocks.ExpectCallFunc(exit).With(2).Throw(std::exception());
Guillaume Paris
  • 10,303
  • 14
  • 70
  • 145
4
votes
1 answer

HippoMock : mocking just a part of class

I would like to know if with HippoMock it is possible to mock just a parts of a class. Example class aClass { public: virtual void method1() = 0; void method2(){ do doSomething; // not a functon …
Ambroise
  • 41
  • 3
3
votes
1 answer

HippoMocks - How to mock Win32 API Function

HippoMocks documentation says that it can mock C function including Windows API function, but I could not find any example for it. Can anyone give an example for windows API function…
goto
  • 433
  • 3
  • 13
3
votes
1 answer

Mock function with arguments as pointer

I have a function: void setData(int *ptr) { *ptr = 3 }; Can I use Hippomock to mock this function and set the value of ptr? Something like: mock.OnCallFunc(setData).With(int *ptr).Do({ *ptr = 5;}); So I can do something like this later int…
Samantha
  • 284
  • 1
  • 11
3
votes
2 answers

NotImplementedException in Hippomock's MockRepository::BasicRegisterExpect

While trying to register an expectation using Hippomock's MockRepository::ExpectCall I encounter the NotImplementedException exception at MockRepository::BasicRegisterExpect's following line which I admittedly do not understand: if ((unsigned…
Roland Sarrazin
  • 1,203
  • 11
  • 29
3
votes
2 answers

HippoMocks insists on destroying mock

IEmployeeServiceProxy* empSvcMock = m_Mocks.InterfaceMock(); m_EmpSvcMock.reset(empSvcMock); // shared_ptr because my class Client ctor expects a shared_ptr Client client(m_EmpSvcMock); how to prevent…
Zach Saw
  • 4,308
  • 3
  • 33
  • 49
2
votes
3 answers

HippoMocks - Use of "ExpectCallFunc" after "NeverCallFunc" for the same function leads to unexpected "HippoMocks::ExpectationException"

Imagine we have a unit test that first executes a sequence of code for which we expect a function someFunc not to be called, then executes a sequence of code for which we expect that function to be called exactly once. Using HippoMocks, we could…
FreakinGeek
  • 51
  • 1
  • 6
2
votes
1 answer

Template function in argument of Expect call function in Hippomock

I want to isolate writeMemory but i can't because of the following error: ../../Util/UnitTest++/../../UnitTests/KeeperDive_Test.h:66:57: error: expected expression mocks.ExpectCall(Skillmock, Skill::writeMemory).With(template (Skillmock)); class…
1
vote
2 answers

Why is my Hippomock expectation failing when using multiple inheritance

I am using Hippomocks and have a class that implements an generic interface. When I place expectations on this class I do not get the expected behaviour. This is my minimum "working" example template struct Foo { virtual ~Foo() =…
Jesse Ryan
  • 73
  • 6
1
vote
1 answer

Compilation error looser throw specifier for gtest derived classes with HippoMocks member in C++11

I am getting below error while compiling my test cases derived from testing::Test of google test with C++11. Below error will be thrown if my derived class has HippoMock::MockRepository member. looser throw specifier for virtual…
sameer chaudhari
  • 928
  • 7
  • 14
1
vote
1 answer

HippoMocks throws NotImplementedException when not specifying expectation

I am investigating using mocking for unit tests I'm adding to existing code. For this I'm using HippoMocks. This involves another class calling some methods on my mock (that are all virtual). I want to avoid overspecifying all this but HippoMocks…
Sebastian Ärleryd
  • 1,774
  • 14
  • 19
1
vote
1 answer

Is HippoMocks thread-safe?

Could HippoMocks be used within concurrent testcases just like this: synchronized startup phase create mock register expectations etc. parallel testing phase call methods on the mock synchronized teardown phase verify the mock I did not find…
Rosepeter
  • 13
  • 2
1
vote
0 answers

Can Hippomocks set expectations for the same MockRepository in different source files?

I would like to have multiple tests in multiple files be able to call a separately-compiled utility method from another file that sets up the same expectations for each test. However, Hippomocks seems to have a problem with setting expectations for…
Andy Evans
  • 171
  • 5
1
vote
1 answer

Hippomocks - mocking function with variable count of args

Hippomocks have OnCallFuncOverload macro for mocking overloaded function call. I'm trying to use for mocking function with variable count of args. Can anyone give an example for overloaded function with variable count of args? My code void…
kindrich
  • 13
  • 6
1
2 3