rollbear / trompeloeil

Header only C++14 mocking framework
Boost Software License 1.0
802 stars 85 forks source link

Can't seem to mock a call to a function that lives on a windows dll when that dll is loaded #305

Open alexapio opened 1 year ago

alexapio commented 1 year ago

Hi, The code I'm testing is on a Windows dll. I wrote a test program that links in the dll and runs tests on it. It looks like this: test_runner<-library<-collaborator (another library being mocked).

This pseudocode fails with "mock_func not called" and upon step-debugging I step into the real function. REQUIRE_CALL(mock_api, mockedfunc()).RETURN(retval); err = mocked_func(arg); REQUIRE(err == ERR_OK);

I'm assuming (haven't verified) that Windows us loading the real collaborator library (as it's a dependency for it) and then the test binary runs that code instead of the mocked call. The issue is that I can't run tests that mock return values to test error handling.

Does this make sense? I'm a firmware guy, my windows-fu is not the strongest.

Thanks!

rollbear commented 1 year ago

I'm afraid I don't understand the problem at all, but I'm almost certainly even less of a windows person.