You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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, mocked_func(_)).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!
The text was updated successfully, but these errors were encountered:
alexapio
changed the title
Can't seem to mock a function on a windows dll
Can't seem to mock a call to a function that lives on a windows dll when that dll is loaded
Jul 10, 2023
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, mocked_func(_)).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!
The text was updated successfully, but these errors were encountered: